Ticket #1191: patchpngtga.diff

File patchpngtga.diff, 1.8 KB (added by Carl Eugen Hoyos, 15 years ago)
  • libavcodec/pngenc.c

    diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
    index c29435b..7622f50 100644
    a b  
    2323#include "bytestream.h"
    2424#include "dsputil.h"
    2525#include "png.h"
     26#include "libavutil/pixdesc.h"
    2627
    2728/* TODO:
    2829 * - add 2, 4 and 16 bit depth support
    … … static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,  
    232233    p->key_frame= 1;
    233234
    234235    is_progressive = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
     236    avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);
    235237    switch(avctx->pix_fmt) {
    236238    case PIX_FMT_RGBA64BE:
    237239        bit_depth = 16;
    … … static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,  
    250252        color_type = PNG_COLOR_TYPE_RGB;
    251253        break;
    252254    case PIX_FMT_GRAY16BE:
     255        avctx->bits_per_coded_sample = 0x30;
    253256        bit_depth = 16;
    254257        color_type = PNG_COLOR_TYPE_GRAY;
    255258        break;
    256259    case PIX_FMT_GRAY8:
     260        avctx->bits_per_coded_sample = 0x28;
    257261        bit_depth = 8;
    258262        color_type = PNG_COLOR_TYPE_GRAY;
    259263        break;
  • libavcodec/targaenc.c

    diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
    index a80053b..77446d8 100644
    a b static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,  
    9696    /* image descriptor byte: origin is always top-left, bits 0-3 specify alpha */
    9797    pkt->data[17] = 0x20 | (avctx->pix_fmt == PIX_FMT_BGRA ? 8 : 0);
    9898
     99    avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);
    99100    switch(avctx->pix_fmt) {
    100101    case PIX_FMT_GRAY8:
    101102        pkt->data[2]  = TGA_BW;     /* uncompressed grayscale image */
     103        avctx->bits_per_coded_sample = 0x28;
    102104        pkt->data[16] = 8;          /* bpp */
    103105        break;
    104106    case PIX_FMT_RGB555LE: