| 964 | } |
| 965 | |
| 966 | static int h264_slice_header_init(H264Context *h) |
| 967 | { |
| 968 | const SPS *sps = h->ps.sps; |
| 969 | int i, ret; |
| 970 | |
| 971 | if (!sps) { |
| 972 | ret = AVERROR_INVALIDDATA; |
| 973 | goto fail; |
| 974 | } |
| 975 | |
| 976 | ff_set_sar(h->avctx, sps->vui.sar); |
| 977 | av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt, |
| 978 | &h->chroma_x_shift, &h->chroma_y_shift); |
| 979 | |
| 980 | if (sps->timing_info_present_flag) { |
| 981 | int64_t den = sps->time_scale; |
| 982 | if (h->x264_build < 44U) |
| 983 | den *= 2; |
| 984 | av_reduce(&h->avctx->framerate.den, &h->avctx->framerate.num, |
| 985 | sps->num_units_in_tick * 2, den, 1 << 30); |
| 986 | } |
| 987 | |
| 988 | ff_h264_free_tables(h); |
| 989 | |
| 990 | h->first_field = 0; |
| 991 | h->prev_interlaced_frame = 1; |
| 992 | |
| 993 | init_scan_tables(h); |
| 994 | ret = ff_h264_alloc_tables(h); |
| 995 | if (ret < 0) { |
| 996 | av_log(h->avctx, AV_LOG_ERROR, "Could not allocate memory\n"); |
| 997 | goto fail; |
| 998 | } |
| 999 | |
| 1000 | if (sps->bit_depth_luma < 8 || sps->bit_depth_luma > 14 || |
| 1001 | sps->bit_depth_luma == 11 || sps->bit_depth_luma == 13 |
| 1002 | ) { |
| 1003 | av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n", |
| 1004 | sps->bit_depth_luma); |
| 1005 | ret = AVERROR_INVALIDDATA; |
| 1006 | goto fail; |
| 1007 | } |
| 1008 | |
| 1009 | h->cur_bit_depth_luma = |
| 1010 | h->avctx->bits_per_raw_sample = sps->bit_depth_luma; |
| 1011 | h->cur_chroma_format_idc = sps->chroma_format_idc; |
| 1012 | h->pixel_shift = sps->bit_depth_luma > 8; |
| 1013 | h->chroma_format_idc = sps->chroma_format_idc; |
| 1014 | h->bit_depth_luma = sps->bit_depth_luma; |
| 1015 | |
| 1016 | ff_h264dsp_init(&h->h264dsp, sps->bit_depth_luma, |
| 1017 | sps->chroma_format_idc); |
| 1018 | ff_h264chroma_init(&h->h264chroma, sps->bit_depth_chroma); |
| 1019 | ff_h264qpel_init(&h->h264qpel, sps->bit_depth_luma); |
| 1020 | ff_h264_pred_init(&h->hpc, AV_CODEC_ID_H264, sps->bit_depth_luma, |
| 1021 | sps->chroma_format_idc); |
| 1022 | ff_videodsp_init(&h->vdsp, sps->bit_depth_luma); |
| 1023 |
no test coverage detected