diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-12-07 16:29:07 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-12-07 16:29:07 +0100 |
commit | 857d7194ca6d07fb9fa70c05826895d6b9c5e983 (patch) | |
tree | e8c39b4af492a32e1f3e0cfe71d70c47a7371a31 /libavcodec | |
parent | 6777aa638791d9a95efc5f7cddba7103fbb309b1 (diff) | |
parent | a394959bbee9e41ff121488f251f85e8a8fb3384 (diff) | |
download | ffmpeg-857d7194ca6d07fb9fa70c05826895d6b9c5e983.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
h264: add a pointer for weighted prediction temporary buffer
Conflicts:
libavcodec/h264.c
libavcodec/h264.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h264.c | 26 | ||||
-rw-r--r-- | libavcodec/h264.h | 1 |
2 files changed, 15 insertions, 12 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 41845ca284..2fbdc77e11 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -671,9 +671,9 @@ static av_always_inline void mc_part_weighted(H264Context *h, int n, int square, if (list0 && list1) { /* don't optimize for luma-only case, since B-frames usually * use implicit weights => chroma too. */ - uint8_t *tmp_cb = s->obmc_scratchpad; - uint8_t *tmp_cr = s->obmc_scratchpad + (16 << pixel_shift); - uint8_t *tmp_y = s->obmc_scratchpad + 16 * h->mb_uvlinesize; + uint8_t *tmp_cb = h->bipred_scratchpad; + uint8_t *tmp_cr = h->bipred_scratchpad + (16 << pixel_shift); + uint8_t *tmp_y = h->bipred_scratchpad + 16 * h->mb_uvlinesize; int refn0 = h->ref_cache[0][scan8[n]]; int refn1 = h->ref_cache[1][scan8[n]]; @@ -790,7 +790,7 @@ static void free_tables(H264Context *h, int free_rbsp) continue; av_freep(&hx->top_borders[1]); av_freep(&hx->top_borders[0]); - av_freep(&hx->s.obmc_scratchpad); + av_freep(&hx->bipred_scratchpad); if (free_rbsp) { av_freep(&hx->rbsp_buffer[1]); av_freep(&hx->rbsp_buffer[0]); @@ -915,8 +915,6 @@ int ff_h264_alloc_tables(H264Context *h) h->mb2br_xy[mb_xy] = 8 * (FMO ? mb_xy : (mb_xy % (2 * s->mb_stride))); } - s->obmc_scratchpad = NULL; - if (!h->dequant4_coeff[0]) init_dequant_tables(h); @@ -944,7 +942,7 @@ static void clone_tables(H264Context *dst, H264Context *src, int i) dst->mvd_table[1] = src->mvd_table[1] + i * 8 * 2 * s->mb_stride; dst->direct_table = src->direct_table; dst->list_counts = src->list_counts; - dst->s.obmc_scratchpad = NULL; + dst->bipred_scratchpad = NULL; ff_h264_pred_init(&dst->hpc, src->s.codec_id, src->sps.bit_depth_luma, src->sps.chroma_format_idc); } @@ -1214,15 +1212,13 @@ static int decode_update_thread_context(AVCodecContext *dst, } context_init(h); - /* frame_start may not be called for the next thread (if it's decoding - * a bottom field) so this has to be allocated here */ - h->s.obmc_scratchpad = av_malloc(16 * 6 * s->linesize); } for (i = 0; i < 2; i++) { h->rbsp_buffer[i] = NULL; h->rbsp_buffer_size[i] = 0; } + h->bipred_scratchpad = NULL; h->thread_context[0] = h; @@ -1230,6 +1226,11 @@ static int decode_update_thread_context(AVCodecContext *dst, s->dsp.clear_blocks(h->mb + (24 * 16 << h->pixel_shift)); } + /* frame_start may not be called for the next thread (if it's decoding + * a bottom field) so this has to be allocated here */ + if (!h->bipred_scratchpad) + h->bipred_scratchpad = av_malloc(16 * 6 * s->linesize); + // extradata/NAL handling h->is_avc = h1->is_avc; @@ -1321,8 +1322,8 @@ int ff_h264_frame_start(H264Context *h) /* can't be in alloc_tables because linesize isn't known there. * FIXME: redo bipred weight to not require extra buffer? */ for (i = 0; i < s->slice_context_count; i++) - if (h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad) - h->thread_context[i]->s.obmc_scratchpad = av_malloc(16 * 6 * s->linesize); + if (h->thread_context[i] && !h->thread_context[i]->bipred_scratchpad) + h->thread_context[i]->bipred_scratchpad = av_malloc(16 * 6 * s->linesize); /* Some macroblocks can be accessed before they're available in case * of lost slices, MBAFF or threading. */ @@ -2642,6 +2643,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) "Could not allocate memory for h264\n"); return AVERROR(ENOMEM); } + h->bipred_scratchpad = NULL; if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_SLICE)) { if (context_init(h) < 0) { diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 00a1fc3c5d..4e44fba163 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -595,6 +595,7 @@ typedef struct H264Context { int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs int cur_chroma_format_idc; + uint8_t *bipred_scratchpad; int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low |