aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2015-04-06 20:33:58 +0200
committerAnton Khirnov <anton@khirnov.net>2015-04-29 05:52:57 +0200
commitee62b364be0c30cba83b5ff10a3ca8c3e866ade6 (patch)
treedbffed438d55e49d723eed17ae3a0b236bfdc03c /libavcodec
parent54986d6db9116ef9704b1ce8414ffdb7f1ca127f (diff)
downloadffmpeg-ee62b364be0c30cba83b5ff10a3ca8c3e866ade6.tar.gz
h264: eliminate ff_h264_set_parameter_from_sps()
That function currently does two things -- reinitializing the DSP contexts and setting low_delay based on the SPS values. The former more appropriately belongs in h264_slice_header_init(), while the latter only really makes sense in decode_slice_header(). The third call to ff_h264_set_parameter_from_sps(), done immediately after parsing a new SPS, appears to serve no useful purpose, so it is just dropped. Also, drop now unneeded H264Context.cur_chroma_format_idc.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264.c43
-rw-r--r--libavcodec/h264.h3
-rw-r--r--libavcodec/h264_slice.c40
3 files changed, 31 insertions, 55 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 5acc4634d7..4a3da24502 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -570,7 +570,6 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
h->avctx = avctx;
h->dequant_coeff_pps = -1;
- h->cur_chroma_format_idc = -1;
h->picture_structure = PICT_FRAME;
h->slice_context_count = 1;
@@ -1175,44 +1174,6 @@ int ff_h264_get_profile(SPS *sps)
return profile;
}
-int ff_h264_set_parameter_from_sps(H264Context *h)
-{
- if (h->flags & CODEC_FLAG_LOW_DELAY ||
- (h->sps.bitstream_restriction_flag &&
- !h->sps.num_reorder_frames)) {
- if (h->avctx->has_b_frames > 1 || h->delayed_pic[0])
- av_log(h->avctx, AV_LOG_WARNING, "Delayed frames seen. "
- "Reenabling low delay requires a codec flush.\n");
- else
- h->low_delay = 1;
- }
-
- if (h->avctx->has_b_frames < 2)
- h->avctx->has_b_frames = !h->low_delay;
-
- if (h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
- h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
- if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
- h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
- h->cur_chroma_format_idc = h->sps.chroma_format_idc;
- h->pixel_shift = h->sps.bit_depth_luma > 8;
-
- ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
- h->sps.chroma_format_idc);
- ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
- ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
- ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
- h->sps.chroma_format_idc);
- ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
- } else {
- av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n",
- h->sps.bit_depth_luma);
- return AVERROR_INVALIDDATA;
- }
- }
- return 0;
-}
-
int ff_set_ref_count(H264Context *h, H264SliceContext *sl)
{
int ref_count[2], list_count;
@@ -1559,10 +1520,6 @@ again:
ff_h264_decode_seq_parameter_set(h);
}
- ret = ff_h264_set_parameter_from_sps(h);
- if (ret < 0)
- goto end;
-
break;
case NAL_PPS:
init_get_bits(&h->gb, ptr, bit_length);
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 821b609b7f..9ca4edac3d 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -724,8 +724,6 @@ typedef struct H264Context {
int sei_buffering_period_present; ///< Buffering period SEI flag
int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
- int cur_chroma_format_idc;
-
int enable_er;
AVBufferPool *qscale_table_pool;
@@ -1073,7 +1071,6 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src);
void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl);
-int ff_h264_set_parameter_from_sps(H264Context *h);
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height);
int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc);
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 864ee980ef..da394d19e4 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -428,11 +428,6 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
h->sps.bit_depth_luma != h1->sps.bit_depth_luma ||
h->sps.chroma_format_idc != h1->sps.chroma_format_idc ||
h->sps.colorspace != h1->sps.colorspace)) {
-
- /* set bits_per_raw_sample to the previous value. the check for changed
- * bit depth in h264_set_parameter_from_sps() uses it and sets it to
- * the current value */
- h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
need_reinit = 1;
}
@@ -571,8 +566,6 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
/* copy block_offset since frame_start may not be called */
memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
-
- ff_h264_set_parameter_from_sps(h);
}
if (!h->cur_pic_ptr)
@@ -1012,6 +1005,23 @@ static int h264_slice_header_init(H264Context *h, int reinit)
return ret;
}
+ if (h->sps.bit_depth_luma < 8 || h->sps.bit_depth_luma > 10) {
+ av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n",
+ h->sps.bit_depth_luma);
+ return AVERROR_INVALIDDATA;
+ }
+
+ h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
+ h->pixel_shift = h->sps.bit_depth_luma > 8;
+
+ ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
+ h->sps.chroma_format_idc);
+ ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
+ ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
+ ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
+ h->sps.chroma_format_idc);
+ ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
+
if (nb_slices > H264_MAX_THREADS || (nb_slices > h->mb_height && h->mb_height)) {
int max_slices;
if (h->mb_height)
@@ -1152,8 +1162,20 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
h->chroma_format_idc = h->sps.chroma_format_idc;
needs_reinit = 1;
}
- if ((ret = ff_h264_set_parameter_from_sps(h)) < 0)
- return ret;
+
+ if (h->flags & CODEC_FLAG_LOW_DELAY ||
+ (h->sps.bitstream_restriction_flag &&
+ !h->sps.num_reorder_frames)) {
+ if (h->avctx->has_b_frames > 1 || h->delayed_pic[0])
+ av_log(h->avctx, AV_LOG_WARNING, "Delayed frames seen. "
+ "Reenabling low delay requires a codec flush.\n");
+ else
+ h->low_delay = 1;
+ }
+
+ if (h->avctx->has_b_frames < 2)
+ h->avctx->has_b_frames = !h->low_delay;
+
}
h->avctx->profile = ff_h264_get_profile(&h->sps);