comparison rawdec.c @ 5419:67acef686665 libavcodec

support raw 4bpp avi fixes dance1.avi closes issue40
author michael
date Sun, 29 Jul 2007 13:32:53 +0000
parents 810df021dbef
children aa954496a445
comparison
equal deleted inserted replaced
5418:95234f2e0bdd 5419:67acef686665
32 int length; /* number of bytes in buffer */ 32 int length; /* number of bytes in buffer */
33 AVFrame pic; ///< AVCodecContext.coded_frame 33 AVFrame pic; ///< AVCodecContext.coded_frame
34 } RawVideoContext; 34 } RawVideoContext;
35 35
36 static const PixelFormatTag pixelFormatBpsAVI[] = { 36 static const PixelFormatTag pixelFormatBpsAVI[] = {
37 { PIX_FMT_PAL8, 4 },
37 { PIX_FMT_PAL8, 8 }, 38 { PIX_FMT_PAL8, 8 },
38 { PIX_FMT_RGB555, 15 }, 39 { PIX_FMT_RGB555, 15 },
39 { PIX_FMT_RGB555, 16 }, 40 { PIX_FMT_RGB555, 16 },
40 { PIX_FMT_BGR24, 24 }, 41 { PIX_FMT_BGR24, 24 },
41 { PIX_FMT_RGB32, 32 }, 42 { PIX_FMT_RGB32, 32 },
103 AVPicture * picture = (AVPicture *) data; 104 AVPicture * picture = (AVPicture *) data;
104 105
105 frame->interlaced_frame = avctx->coded_frame->interlaced_frame; 106 frame->interlaced_frame = avctx->coded_frame->interlaced_frame;
106 frame->top_field_first = avctx->coded_frame->top_field_first; 107 frame->top_field_first = avctx->coded_frame->top_field_first;
107 108
109 //4bpp raw in avi (yes this is ugly ...)
110 if(avctx->bits_per_sample == 4 && avctx->pix_fmt==PIX_FMT_PAL8 && !avctx->codec_tag){
111 int i;
112 for(i=256*2; i+1 < context->length>>1; i++){
113 context->buffer[2*i+0]= buf[i-256*2]>>4;
114 context->buffer[2*i+1]= buf[i-256*2]&15;
115 }
116 buf= context->buffer + 256*4;
117 buf_size= context->length - 256*4;
118 }
119
108 if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0)) 120 if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
109 return -1; 121 return -1;
110 122
111 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); 123 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height);
112 if(avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length){ 124 if(avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length){