[FFmpeg-devel] [PATCH 3/6] avcodec/rawdec: for 16-bit bayer images, shift pixels according to bits_per_coded_sample

Michael Niedermayer michaelni at gmx.at
Sat Feb 22 20:50:19 CET 2014


On Sat, Feb 22, 2014 at 11:41:49PM +1100, Peter Ross wrote:
> ---
>  libavcodec/rawdec.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
> index e1682e3..c0f252b 100644
> --- a/libavcodec/rawdec.c
> +++ b/libavcodec/rawdec.c
> @@ -240,6 +240,39 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
>          return AVERROR(EINVAL);
>      }
>  
> +    if (avctx->bits_per_coded_sample && avctx->bits_per_coded_sample < 16) {
> +        const uint8_t *buf_end = buf + buf_size;
> +        uint8_t *p;
> +        switch (avctx->pix_fmt) {
> +        case AV_PIX_FMT_GRAY16LE:
> +        case AV_PIX_FMT_RGB48LE:
> +        case AV_PIX_FMT_BGR48LE:
> +        case AV_PIX_FMT_YUV420P16LE:
> +        case AV_PIX_FMT_YUV422P16LE:
> +        case AV_PIX_FMT_YUV444P16LE:
> +        case AV_PIX_FMT_BAYER_BGGR16LE:
> +        case AV_PIX_FMT_BAYER_RGGB16LE:
> +        case AV_PIX_FMT_BAYER_GBRG16LE:
> +        case AV_PIX_FMT_BAYER_GRBG16LE:
> +            for (p = (uint8_t *)buf; buf_end - p >= 2; p += 2)
> +                AV_WL16(p, AV_RL16(p) << (16 - avctx->bits_per_coded_sample));

this writes into the input buffer which is const
need_copy would need to be set


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140222/90986ca8/attachment.asc>


More information about the ffmpeg-devel mailing list