diff options
Diffstat (limited to 'libavcodec/svq3.c')
-rw-r--r-- | libavcodec/svq3.c | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 23ab209..30cd0f1 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -1,20 +1,20 @@ /* - * Copyright (c) 2003 The Libav Project + * 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 */ @@ -37,7 +37,7 @@ * * You will know you have these parameters passed correctly when the decoder * correctly decodes this file: - * http://samples.libav.org/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov + * http://samples.mplayerhq.hu/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov */ #include "internal.h" #include "dsputil.h" @@ -70,6 +70,8 @@ typedef struct { int unknown_flag; int next_slice_index; uint32_t watermark_key; + uint8_t *buf; + int buf_size; } SVQ3Context; #define FULLPEL_MODE 1 @@ -827,6 +829,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) svq3->thirdpel_flag = 1; svq3->unknown_flag = 0; + /* prowl for the "SEQH" marker in the extradata */ extradata = (unsigned char *)avctx->extradata; for (m = 0; m < avctx->extradata_size; m++) { @@ -932,12 +935,12 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; SVQ3Context *svq3 = avctx->priv_data; H264Context *h = &svq3->h; MpegEncContext *s = &h->s; int buf_size = avpkt->size; - int m, mb_type; + int m, mb_type, left; + uint8_t *buf; /* special case for last picture */ if (buf_size == 0) { @@ -949,10 +952,21 @@ static int svq3_decode_frame(AVCodecContext *avctx, return 0; } - init_get_bits (&s->gb, buf, 8*buf_size); - s->mb_x = s->mb_y = h->mb_xy = 0; + if (svq3->watermark_key) { + av_fast_malloc(&svq3->buf, &svq3->buf_size, + buf_size+FF_INPUT_BUFFER_PADDING_SIZE); + if (!svq3->buf) + return AVERROR(ENOMEM); + memcpy(svq3->buf, avpkt->data, buf_size); + buf = svq3->buf; + } else { + buf = avpkt->data; + } + + init_get_bits(&s->gb, buf, 8*buf_size); + if (svq3_decode_slice_header(avctx)) return -1; @@ -1059,6 +1073,18 @@ static int svq3_decode_frame(AVCodecContext *avctx, ff_draw_horiz_band(s, 16*s->mb_y, 16); } + left = buf_size*8 - get_bits_count(&s->gb); + + if (s->mb_y != s->mb_height || s->mb_x != s->mb_width) { + av_log(avctx, AV_LOG_INFO, "frame num %d incomplete pic x %d y %d left %d\n", avctx->frame_number, s->mb_y, s->mb_x, left); + //av_hex_dump(stderr, buf+buf_size-8, 8); + } + + if (left < 0) { + av_log(avctx, AV_LOG_ERROR, "frame num %d left %d\n", avctx->frame_number, left); + return -1; + } + MPV_frame_end(s); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { @@ -1085,6 +1111,9 @@ static int svq3_decode_end(AVCodecContext *avctx) MPV_common_end(s); + av_freep(&svq3->buf); + svq3->buf_size = 0; + return 0; } |