]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rawdec.c
cosmetics: Fix typos in ADPCM codec long names.
[ffmpeg] / libavcodec / rawdec.c
index 87fa295641d101ef6a6b08b5735d3dabae7a3de0..f03b1a265f4c987f333a1a14eee9137c6705e922 100644 (file)
@@ -34,6 +34,7 @@ typedef struct RawVideoContext {
 } RawVideoContext;
 
 static const PixelFormatTag pixelFormatBpsAVI[] = {
+    { PIX_FMT_PAL8,    4 },
     { PIX_FMT_PAL8,    8 },
     { PIX_FMT_RGB555, 15 },
     { PIX_FMT_RGB555, 16 },
@@ -45,6 +46,7 @@ static const PixelFormatTag pixelFormatBpsAVI[] = {
 static const PixelFormatTag pixelFormatBpsMOV[] = {
     /* FIXME fix swscaler to support those */
     /* http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html */
+    { PIX_FMT_PAL8,      4 },
     { PIX_FMT_PAL8,      8 },
     { PIX_FMT_BGR555,   16 },
     { PIX_FMT_RGB24,    24 },
@@ -62,7 +64,7 @@ static int findPixelFormat(const PixelFormatTag *tags, unsigned int fourcc)
     return PIX_FMT_YUV420P;
 }
 
-static int raw_init_decoder(AVCodecContext *avctx)
+static av_cold int raw_init_decoder(AVCodecContext *avctx)
 {
     RawVideoContext *context = avctx->priv_data;
 
@@ -95,7 +97,7 @@ static void flip(AVCodecContext *avctx, AVPicture * picture){
 
 static int raw_decode(AVCodecContext *avctx,
                             void *data, int *data_size,
-                            uint8_t *buf, int buf_size)
+                            const uint8_t *buf, int buf_size)
 {
     RawVideoContext *context = avctx->priv_data;
 
@@ -105,6 +107,18 @@ static int raw_decode(AVCodecContext *avctx,
     frame->interlaced_frame = avctx->coded_frame->interlaced_frame;
     frame->top_field_first = avctx->coded_frame->top_field_first;
 
+    //4bpp raw in avi and mov (yes this is ugly ...)
+    if(avctx->bits_per_sample == 4 && avctx->pix_fmt==PIX_FMT_PAL8 &&
+       (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))){
+        int i;
+        for(i=256*2; i+1 < context->length>>1; i++){
+            context->buffer[2*i+0]= buf[i-256*2]>>4;
+            context->buffer[2*i+1]= buf[i-256*2]&15;
+        }
+        buf= context->buffer + 256*4;
+        buf_size= context->length - 256*4;
+    }
+
     if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
         return -1;
 
@@ -131,7 +145,7 @@ static int raw_decode(AVCodecContext *avctx,
     return buf_size;
 }
 
-static int raw_close_decoder(AVCodecContext *avctx)
+static av_cold int raw_close_decoder(AVCodecContext *avctx)
 {
     RawVideoContext *context = avctx->priv_data;
 
@@ -148,4 +162,5 @@ AVCodec rawvideo_decoder = {
     NULL,
     raw_close_decoder,
     raw_decode,
+    .long_name = "raw video",
 };