diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/svq1dec.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/svq1dec.c')
| -rw-r--r-- | ffmpeg/libavcodec/svq1dec.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/ffmpeg/libavcodec/svq1dec.c b/ffmpeg/libavcodec/svq1dec.c index c71b361..1e7ab49 100644 --- a/ffmpeg/libavcodec/svq1dec.c +++ b/ffmpeg/libavcodec/svq1dec.c @@ -34,6 +34,7 @@ #include "avcodec.h" #include "get_bits.h" +#include "h263.h" #include "hpeldsp.h" #include "internal.h" #include "mathops.h" @@ -42,8 +43,6 @@ #undef NDEBUG #include <assert.h> -extern const uint8_t ff_mvtab[33][2]; - static VLC svq1_block_type; static VLC svq1_motion_component; static VLC svq1_intra_multistage[6]; @@ -321,7 +320,8 @@ static void svq1_skip_block(uint8_t *current, uint8_t *previous, static int svq1_motion_inter_block(HpelDSPContext *hdsp, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, - int pitch, svq1_pmv *motion, int x, int y) + int pitch, svq1_pmv *motion, int x, int y, + int width, int height) { uint8_t *src; uint8_t *dst; @@ -350,10 +350,8 @@ static int svq1_motion_inter_block(HpelDSPContext *hdsp, GetBitContext *bitbuf, motion[x / 8 + 2].y = motion[x / 8 + 3].y = mv.y; - if (y + (mv.y >> 1) < 0) - mv.y = 0; - if (x + (mv.x >> 1) < 0) - mv.x = 0; + mv.x = av_clip(mv.x, -2 * x, 2 * (width - x - 16)); + mv.y = av_clip(mv.y, -2 * y, 2 * (height - y - 16)); src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1)) * pitch]; dst = current; @@ -365,7 +363,8 @@ static int svq1_motion_inter_block(HpelDSPContext *hdsp, GetBitContext *bitbuf, static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, - int pitch, svq1_pmv *motion, int x, int y) + int pitch, svq1_pmv *motion, int x, int y, + int width, int height) { uint8_t *src; uint8_t *dst; @@ -421,10 +420,8 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu int mvy = pmv[i]->y + (i >> 1) * 16; // FIXME: clipping or padding? - if (y + (mvy >> 1) < 0) - mvy = 0; - if (x + (mvx >> 1) < 0) - mvx = 0; + mvx = av_clip(mvx, -2 * x, 2 * (width - x - 8)); + mvy = av_clip(mvy, -2 * y, 2 * (height - y - 8)); src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1)) * pitch]; dst = current; @@ -444,7 +441,8 @@ static int svq1_motion_inter_4v_block(HpelDSPContext *hdsp, GetBitContext *bitbu static int svq1_decode_delta_block(AVCodecContext *avctx, HpelDSPContext *hdsp, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, - int pitch, svq1_pmv *motion, int x, int y) + int pitch, svq1_pmv *motion, int x, int y, + int width, int height) { uint32_t block_type; int result = 0; @@ -469,7 +467,7 @@ static int svq1_decode_delta_block(AVCodecContext *avctx, HpelDSPContext *hdsp, case SVQ1_BLOCK_INTER: result = svq1_motion_inter_block(hdsp, bitbuf, current, previous, - pitch, motion, x, y); + pitch, motion, x, y, width, height); if (result != 0) { av_dlog(avctx, "Error in svq1_motion_inter_block %i\n", result); @@ -480,7 +478,7 @@ static int svq1_decode_delta_block(AVCodecContext *avctx, HpelDSPContext *hdsp, case SVQ1_BLOCK_INTER_4V: result = svq1_motion_inter_4v_block(hdsp, bitbuf, current, previous, - pitch, motion, x, y); + pitch, motion, x, y, width, height); if (result != 0) { av_dlog(avctx, "Error in svq1_motion_inter_4v_block %i\n", result); @@ -556,7 +554,7 @@ static int svq1_decode_frame_header(AVCodecContext *avctx, AVFrame *frame) svq1_parse_string(bitbuf, msg); av_log(avctx, AV_LOG_INFO, - "embedded message: \"%s\"\n", (char *)msg); + "embedded message:\n%s\n", (char *)msg); } skip_bits(bitbuf, 2); @@ -595,8 +593,8 @@ static int svq1_decode_frame_header(AVCodecContext *avctx, AVFrame *frame) skip_bits1(bitbuf); skip_bits(bitbuf, 2); - while (get_bits1(bitbuf)) - skip_bits(bitbuf, 8); + if (skip_1stop_8data_bits(bitbuf) < 0) + return AVERROR_INVALIDDATA; } s->width = width; @@ -616,7 +614,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data, svq1_pmv *pmv; /* initialize bit buffer */ - init_get_bits(&s->gb, buf, buf_size * 8); + init_get_bits8(&s->gb, buf, buf_size); /* decode frame header */ s->frame_code = get_bits(&s->gb, 22); @@ -640,7 +638,10 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data, av_dlog(avctx, "Error in svq1_decode_frame_header %i\n", result); return result; } - avcodec_set_dimensions(avctx, s->width, s->height); + + result = ff_set_dimensions(avctx, s->width, s->height); + if (result < 0) + return result; if ((avctx->skip_frame >= AVDISCARD_NONREF && s->nonref) || (avctx->skip_frame >= AVDISCARD_NONKEY && @@ -689,7 +690,8 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data, } else { /* delta frame */ uint8_t *previous = s->prev->data[i]; - if (!previous || s->prev->width != cur->width || s->prev->height != cur->height) { + if (!previous || + s->prev->width != s->width || s->prev->height != s->height) { av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n"); result = AVERROR_INVALIDDATA; goto err; @@ -702,8 +704,8 @@ static int svq1_decode_frame(AVCodecContext *avctx, void *data, result = svq1_decode_delta_block(avctx, &s->hdsp, &s->gb, ¤t[x], previous, linesize, - pmv, x, y); - if (result) { + pmv, x, y, width, height); + if (result != 0) { av_dlog(avctx, "Error in svq1_decode_delta_block %i\n", result); @@ -740,7 +742,7 @@ static av_cold int svq1_decode_init(AVCodecContext *avctx) int i; int offset = 0; - s->prev = avcodec_alloc_frame(); + s->prev = av_frame_alloc(); if (!s->prev) return AVERROR(ENOMEM); @@ -807,6 +809,7 @@ static void svq1_flush(AVCodecContext *avctx) AVCodec ff_svq1_decoder = { .name = "svq1", + .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_SVQ1, .priv_data_size = sizeof(SVQ1Context), @@ -817,5 +820,4 @@ AVCodec ff_svq1_decoder = { .flush = svq1_flush, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV410P, AV_PIX_FMT_NONE }, - .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), }; |
