diff options
Diffstat (limited to 'libavcodec/cyuv.c')
-rw-r--r-- | libavcodec/cyuv.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/libavcodec/cyuv.c b/libavcodec/cyuv.c index 6b9d5b9307..b3bf4f2b09 100644 --- a/libavcodec/cyuv.c +++ b/libavcodec/cyuv.c @@ -6,20 +6,20 @@ * * Copyright (C) 2003 the ffmpeg project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -53,7 +53,7 @@ static av_cold int cyuv_decode_init(AVCodecContext *avctx) if (s->width & 0x3) return AVERROR_INVALIDDATA; s->height = avctx->height; - avctx->pix_fmt = AV_PIX_FMT_YUV411P; + avcodec_get_frame_defaults(&s->frame); return 0; } @@ -82,6 +82,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx, int stream_ptr; unsigned char cur_byte; int pixel_groups; + int rawsize = s->height * FFALIGN(s->width,2) * 2; int ret; if (avctx->codec_id == AV_CODEC_ID_AURA) { @@ -92,7 +93,11 @@ static int cyuv_decode_frame(AVCodecContext *avctx, * followed by (height) lines each with 3 bytes to represent groups * of 4 pixels. Thus, the total size of the buffer ought to be: * (3 * 16) + height * (width * 3 / 4) */ - if (buf_size != 48 + s->height * (s->width * 3 / 4)) { + if (buf_size == 48 + s->height * (s->width * 3 / 4)) { + avctx->pix_fmt = AV_PIX_FMT_YUV411P; + } else if(buf_size == rawsize ) { + avctx->pix_fmt = AV_PIX_FMT_UYVY422; + } else { av_log(avctx, AV_LOG_ERROR, "got a buffer with %d bytes when %d were expected\n", buf_size, 48 + s->height * (s->width * 3 / 4)); return AVERROR_INVALIDDATA; @@ -115,6 +120,15 @@ static int cyuv_decode_frame(AVCodecContext *avctx, u_plane = s->frame.data[1]; v_plane = s->frame.data[2]; + if (buf_size == rawsize) { + int linesize = FFALIGN(s->width,2) * 2; + y_plane += s->frame.linesize[0] * s->height; + for (stream_ptr = 0; stream_ptr < rawsize; stream_ptr += linesize) { + y_plane -= s->frame.linesize[0]; + memcpy(y_plane, buf+stream_ptr, linesize); + } + } else { + /* iterate through each line in the height */ for (y_ptr = 0, u_ptr = 0, v_ptr = 0; y_ptr < (s->height * s->frame.linesize[0]); @@ -162,6 +176,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx, } } + } *got_frame = 1; *(AVFrame*)data= s->frame; |