Mercurial > libavcodec.hg
comparison rawdec.c @ 8993:80720c5427a0 libavcodec
Fix raw rgb/bgr vertical flip in avi based on info from http://www.fourcc.org/fccbihgt.php.
partially fixes issue862.
author | michael |
---|---|
date | Sat, 21 Feb 2009 15:32:56 +0000 |
parents | e9d9d946f213 |
children | 231e8535e00e |
comparison
equal
deleted
inserted
replaced
8992:5a3426d7d053 | 8993:80720c5427a0 |
---|---|
28 #include "raw.h" | 28 #include "raw.h" |
29 | 29 |
30 typedef struct RawVideoContext { | 30 typedef struct RawVideoContext { |
31 unsigned char * buffer; /* block of memory for holding one frame */ | 31 unsigned char * buffer; /* block of memory for holding one frame */ |
32 int length; /* number of bytes in buffer */ | 32 int length; /* number of bytes in buffer */ |
33 int flip; | |
33 AVFrame pic; ///< AVCodecContext.coded_frame | 34 AVFrame pic; ///< AVCodecContext.coded_frame |
34 } RawVideoContext; | 35 } RawVideoContext; |
35 | 36 |
36 static const PixelFormatTag pixelFormatBpsAVI[] = { | 37 static const PixelFormatTag pixelFormatBpsAVI[] = { |
37 { PIX_FMT_PAL8, 4 }, | 38 { PIX_FMT_PAL8, 4 }, |
83 avctx->coded_frame= &context->pic; | 84 avctx->coded_frame= &context->pic; |
84 | 85 |
85 if (!context->buffer) | 86 if (!context->buffer) |
86 return -1; | 87 return -1; |
87 | 88 |
89 if(avctx->extradata_size >= 9 && !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9)) | |
90 context->flip=1; | |
91 | |
88 return 0; | 92 return 0; |
89 } | 93 } |
90 | 94 |
91 static void flip(AVCodecContext *avctx, AVPicture * picture){ | 95 static void flip(AVCodecContext *avctx, AVPicture * picture){ |
92 if(!avctx->codec_tag && avctx->bits_per_coded_sample && picture->linesize[2]==0){ | |
93 picture->data[0] += picture->linesize[0] * (avctx->height-1); | 96 picture->data[0] += picture->linesize[0] * (avctx->height-1); |
94 picture->linesize[0] *= -1; | 97 picture->linesize[0] *= -1; |
95 } | |
96 } | 98 } |
97 | 99 |
98 static int raw_decode(AVCodecContext *avctx, | 100 static int raw_decode(AVCodecContext *avctx, |
99 void *data, int *data_size, | 101 void *data, int *data_size, |
100 const uint8_t *buf, int buf_size) | 102 const uint8_t *buf, int buf_size) |
129 if (avctx->palctrl && avctx->palctrl->palette_changed) { | 131 if (avctx->palctrl && avctx->palctrl->palette_changed) { |
130 memcpy(frame->data[1], avctx->palctrl->palette, AVPALETTE_SIZE); | 132 memcpy(frame->data[1], avctx->palctrl->palette, AVPALETTE_SIZE); |
131 avctx->palctrl->palette_changed = 0; | 133 avctx->palctrl->palette_changed = 0; |
132 } | 134 } |
133 | 135 |
136 if(context->flip) | |
134 flip(avctx, picture); | 137 flip(avctx, picture); |
135 | 138 |
136 if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2')) | 139 if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2')) |
137 { | 140 { |
138 // swap fields | 141 // swap fields |