[FFmpeg-cvslog] h264: add a pointer for weighted prediction temporary buffer
Janne Grunau
git at videolan.org
Fri Dec 7 17:04:25 CET 2012
ffmpeg | branch: master | Janne Grunau <janne-libav at jannau.net> | Tue Nov 27 19:12:45 2012 +0100| [a394959bbee9e41ff121488f251f85e8a8fb3384] | committer: Janne Grunau
h264: add a pointer for weighted prediction temporary buffer
Reusing MpegEncContext's obmc_scratchpad for this becomes a mess with
adaptive frame-mt.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a394959bbee9e41ff121488f251f85e8a8fb3384
---
libavcodec/h264.c | 26 +++++++++++++-------------
libavcodec/h264.h | 1 +
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 0525caa..36f4c60 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -652,9 +652,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]];
@@ -773,7 +773,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]);
@@ -898,8 +898,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);
@@ -927,7 +925,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);
}
@@ -1172,17 +1170,19 @@ static int decode_update_thread_context(AVCodecContext *dst,
h->rbsp_buffer[i] = NULL;
h->rbsp_buffer_size[i] = 0;
}
+ h->bipred_scratchpad = NULL;
h->thread_context[0] = 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);
-
s->dsp.clear_blocks(h->mb);
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;
@@ -1272,8 +1272,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. */
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 570ce2f..b8ded57 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -578,6 +578,7 @@ typedef struct H264Context {
int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
int cur_chroma_format_idc;
+ uint8_t *bipred_scratchpad;
} H264Context;
extern const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM + 1]; ///< One chroma qp table for each supported bit depth (8, 9, 10).
More information about the ffmpeg-cvslog
mailing list