Mercurial > libavcodec.hg
comparison rawdec.c @ 10772:c76ee970d3bd libavcodec
Support decoding raw 2bpp in mov, fixes issue 1528.
| author | cehoyos |
|---|---|
| date | Tue, 05 Jan 2010 01:11:45 +0000 |
| parents | cea7769a2b62 |
| children | 8413193405c5 |
comparison
equal
deleted
inserted
replaced
| 10771:cea7769a2b62 | 10772:c76ee970d3bd |
|---|---|
| 45 { PIX_FMT_NONE, 0 }, | 45 { PIX_FMT_NONE, 0 }, |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 static const PixelFormatTag pixelFormatBpsMOV[] = { | 48 static const PixelFormatTag pixelFormatBpsMOV[] = { |
| 49 { PIX_FMT_MONOWHITE, 1 }, | 49 { PIX_FMT_MONOWHITE, 1 }, |
| 50 { PIX_FMT_PAL8, 2 }, | |
| 50 { PIX_FMT_PAL8, 4 }, | 51 { PIX_FMT_PAL8, 4 }, |
| 51 { PIX_FMT_PAL8, 8 }, | 52 { PIX_FMT_PAL8, 8 }, |
| 52 // FIXME swscale does not support 16 bit in .mov, sample 16bit.mov | 53 // FIXME swscale does not support 16 bit in .mov, sample 16bit.mov |
| 53 // http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html | 54 // http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html |
| 54 { PIX_FMT_RGB555BE, 16 }, | 55 { PIX_FMT_RGB555BE, 16 }, |
| 113 | 114 |
| 114 frame->interlaced_frame = avctx->coded_frame->interlaced_frame; | 115 frame->interlaced_frame = avctx->coded_frame->interlaced_frame; |
| 115 frame->top_field_first = avctx->coded_frame->top_field_first; | 116 frame->top_field_first = avctx->coded_frame->top_field_first; |
| 116 | 117 |
| 117 //4bpp raw in avi and mov (yes this is ugly ...) | 118 //4bpp raw in avi and mov (yes this is ugly ...) |
| 118 if(avctx->bits_per_coded_sample == 4 && avctx->pix_fmt==PIX_FMT_PAL8 && | 119 if((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) && |
| 120 avctx->pix_fmt==PIX_FMT_PAL8 && | |
| 119 (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))){ | 121 (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))){ |
| 120 int i; | 122 int i; |
| 121 uint8_t *dst = context->buffer + 256*4; | 123 uint8_t *dst = context->buffer + 256*4; |
| 122 buf_size = context->length - 256*4; | 124 buf_size = context->length - 256*4; |
| 125 if (avctx->bits_per_coded_sample == 4){ | |
| 123 for(i=0; 2*i+1 < buf_size; i++){ | 126 for(i=0; 2*i+1 < buf_size; i++){ |
| 124 dst[2*i+0]= buf[i]>>4; | 127 dst[2*i+0]= buf[i]>>4; |
| 125 dst[2*i+1]= buf[i]&15; | 128 dst[2*i+1]= buf[i]&15; |
| 126 } | 129 } |
| 130 } else | |
| 131 for(i=0; 4*i+3 < buf_size; i++){ | |
| 132 dst[4*i+0]= buf[i]>>6; | |
| 133 dst[4*i+1]= buf[i]>>4&3; | |
| 134 dst[4*i+2]= buf[i]>>2&3; | |
| 135 dst[4*i+3]= buf[i] &3; | |
| 136 } | |
| 127 buf= dst; | 137 buf= dst; |
| 128 } | 138 } |
| 129 | 139 |
| 130 if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0)) | 140 if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0)) |
| 131 return -1; | 141 return -1; |
