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/vp3.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/vp3.c')
| -rw-r--r-- | ffmpeg/libavcodec/vp3.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/ffmpeg/libavcodec/vp3.c b/ffmpeg/libavcodec/vp3.c index 1e76786..626642f 100644 --- a/ffmpeg/libavcodec/vp3.c +++ b/ffmpeg/libavcodec/vp3.c @@ -381,7 +381,8 @@ static void init_dequantizer(Vp3DecodeContext *s, int qpi) int qmin= 8<<(inter + !i); int qscale= i ? ac_scale_factor : dc_scale_factor; - s->qmat[qpi][inter][plane][s->idct_permutation[i]]= av_clip((qscale * coeff)/100 * 4, qmin, 4096); + s->qmat[qpi][inter][plane][s->idct_permutation[i]] = + av_clip((qscale * coeff) / 100 * 4, qmin, 4096); } // all DC coefficients use the same quant so as not to interfere with DC prediction s->qmat[qpi][inter][plane][0] = s->qmat[0][inter][plane][0]; @@ -1293,7 +1294,7 @@ static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int ye int width = s->fragment_width[!!plane]; int height = s->fragment_height[!!plane]; int fragment = s->fragment_start [plane] + ystart * width; - int stride = s->current_frame.f->linesize[plane]; + ptrdiff_t stride = s->current_frame.f->linesize[plane]; uint8_t *plane_data = s->current_frame.f->data [plane]; if (!s->flipped_image) stride = -stride; plane_data += s->data_offset[plane] + 8*ystart*stride; @@ -1475,7 +1476,7 @@ static void render_slice(Vp3DecodeContext *s, int slice) uint8_t *output_plane = s->current_frame.f->data [plane] + s->data_offset[plane]; uint8_t * last_plane = s-> last_frame.f->data [plane] + s->data_offset[plane]; uint8_t *golden_plane = s-> golden_frame.f->data [plane] + s->data_offset[plane]; - int stride = s->current_frame.f->linesize[plane]; + ptrdiff_t stride = s->current_frame.f->linesize[plane]; int plane_width = s->width >> (plane && s->chroma_x_shift); int plane_height = s->height >> (plane && s->chroma_y_shift); int8_t (*motion_val)[2] = s->motion_val[!!plane]; @@ -1548,7 +1549,11 @@ static void render_slice(Vp3DecodeContext *s, int slice) uint8_t *temp= s->edge_emu_buffer; if(stride<0) temp -= 8*stride; - s->vdsp.emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, plane_width, plane_height); + s->vdsp.emulated_edge_mc(temp, motion_source, + stride, stride, + 9, 9, src_x, src_y, + plane_width, + plane_height); motion_source= temp; } } @@ -1631,16 +1636,16 @@ static av_cold int allocate_tables(AVCodecContext *avctx) y_fragment_count = s->fragment_width[0] * s->fragment_height[0]; c_fragment_count = s->fragment_width[1] * s->fragment_height[1]; - s->superblock_coding = av_malloc(s->superblock_count); - s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment)); - s->coded_fragment_list[0] = av_malloc(s->fragment_count * sizeof(int)); - s->dct_tokens_base = av_malloc(64*s->fragment_count * sizeof(*s->dct_tokens_base)); - s->motion_val[0] = av_malloc(y_fragment_count * sizeof(*s->motion_val[0])); - s->motion_val[1] = av_malloc(c_fragment_count * sizeof(*s->motion_val[1])); + s->superblock_coding = av_mallocz(s->superblock_count); + s->all_fragments = av_mallocz(s->fragment_count * sizeof(Vp3Fragment)); + s->coded_fragment_list[0] = av_mallocz(s->fragment_count * sizeof(int)); + s->dct_tokens_base = av_mallocz(64*s->fragment_count * sizeof(*s->dct_tokens_base)); + s->motion_val[0] = av_mallocz(y_fragment_count * sizeof(*s->motion_val[0])); + s->motion_val[1] = av_mallocz(c_fragment_count * sizeof(*s->motion_val[1])); /* work out the block mapping tables */ - s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int)); - s->macroblock_coding = av_malloc(s->macroblock_count + 1); + s->superblock_fragments = av_mallocz(s->superblock_count * 16 * sizeof(int)); + s->macroblock_coding = av_mallocz(s->macroblock_count + 1); if (!s->superblock_coding || !s->all_fragments || !s->dct_tokens_base || !s->coded_fragment_list[0] || !s->superblock_fragments || !s->macroblock_coding || @@ -2192,6 +2197,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) Vp3DecodeContext *s = avctx->priv_data; int visible_width, visible_height, colorspace; int offset_x = 0, offset_y = 0; + int ret; AVRational fps, aspect; s->theora = get_bits_long(gb, 24); @@ -2208,12 +2214,6 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) visible_width = s->width = get_bits(gb, 16) << 4; visible_height = s->height = get_bits(gb, 16) << 4; - if(av_image_check_size(s->width, s->height, 0, avctx)){ - av_log(avctx, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n", s->width, s->height); - s->width= s->height= 0; - return -1; - } - if (s->theora >= 0x030200) { visible_width = get_bits_long(gb, 24); visible_height = get_bits_long(gb, 24); @@ -2225,6 +2225,10 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) fps.num = get_bits_long(gb, 32); fps.den = get_bits_long(gb, 32); if (fps.num && fps.den) { + if (fps.num < 0 || fps.den < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid framerate\n"); + return AVERROR_INVALIDDATA; + } av_reduce(&avctx->time_base.num, &avctx->time_base.den, fps.den, fps.num, 1<<30); } @@ -2260,9 +2264,11 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) if ( visible_width <= s->width && visible_width > s->width-16 && visible_height <= s->height && visible_height > s->height-16 && !offset_x && (offset_y == s->height - visible_height)) - avcodec_set_dimensions(avctx, visible_width, visible_height); + ret = ff_set_dimensions(avctx, visible_width, visible_height); else - avcodec_set_dimensions(avctx, s->width, s->height); + ret = ff_set_dimensions(avctx, s->width, s->height); + if (ret < 0) + return ret; if (colorspace == 1) { avctx->color_primaries = AVCOL_PRI_BT470M; @@ -2454,6 +2460,7 @@ static av_cold int theora_decode_init(AVCodecContext *avctx) AVCodec ff_theora_decoder = { .name = "theora", + .long_name = NULL_IF_CONFIG_SMALL("Theora"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_THEORA, .priv_data_size = sizeof(Vp3DecodeContext), @@ -2463,7 +2470,6 @@ AVCodec ff_theora_decoder = { .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, - .long_name = NULL_IF_CONFIG_SMALL("Theora"), .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) }; @@ -2471,6 +2477,7 @@ AVCodec ff_theora_decoder = { AVCodec ff_vp3_decoder = { .name = "vp3", + .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP3, .priv_data_size = sizeof(Vp3DecodeContext), @@ -2480,7 +2487,6 @@ AVCodec ff_vp3_decoder = { .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, - .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"), .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context), }; |
