| 1057 | } |
| 1058 | |
| 1059 | static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_slice) |
| 1060 | { |
| 1061 | const SPS *sps; |
| 1062 | int needs_reinit = 0, must_reinit, ret; |
| 1063 | |
| 1064 | if (first_slice) |
| 1065 | av_refstruct_replace(&h->ps.pps, h->ps.pps_list[sl->pps_id]); |
| 1066 | |
| 1067 | if (h->ps.sps != h->ps.pps->sps) { |
| 1068 | h->ps.sps = h->ps.pps->sps; |
| 1069 | |
| 1070 | if (h->mb_width != h->ps.sps->mb_width || |
| 1071 | h->mb_height != h->ps.sps->mb_height || |
| 1072 | h->cur_bit_depth_luma != h->ps.sps->bit_depth_luma || |
| 1073 | h->cur_chroma_format_idc != h->ps.sps->chroma_format_idc |
| 1074 | ) |
| 1075 | needs_reinit = 1; |
| 1076 | |
| 1077 | if (h->bit_depth_luma != h->ps.sps->bit_depth_luma || |
| 1078 | h->chroma_format_idc != h->ps.sps->chroma_format_idc) |
| 1079 | needs_reinit = 1; |
| 1080 | } |
| 1081 | sps = h->ps.sps; |
| 1082 | |
| 1083 | must_reinit = (h->context_initialized && |
| 1084 | ( 16*sps->mb_width != h->avctx->coded_width |
| 1085 | || 16*sps->mb_height != h->avctx->coded_height |
| 1086 | || h->cur_bit_depth_luma != sps->bit_depth_luma |
| 1087 | || h->cur_chroma_format_idc != sps->chroma_format_idc |
| 1088 | || h->mb_width != sps->mb_width |
| 1089 | || h->mb_height != sps->mb_height |
| 1090 | )); |
| 1091 | if (h->avctx->pix_fmt == AV_PIX_FMT_NONE |
| 1092 | || (non_j_pixfmt(h->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h, 0)))) |
| 1093 | must_reinit = 1; |
| 1094 | |
| 1095 | if (first_slice && av_cmp_q(sps->vui.sar, h->avctx->sample_aspect_ratio)) |
| 1096 | must_reinit = 1; |
| 1097 | |
| 1098 | if (!h->setup_finished) { |
| 1099 | h->avctx->profile = ff_h264_get_profile(sps); |
| 1100 | h->avctx->level = sps->level_idc; |
| 1101 | h->avctx->refs = sps->ref_frame_count; |
| 1102 | |
| 1103 | h->mb_width = sps->mb_width; |
| 1104 | h->mb_height = sps->mb_height; |
| 1105 | h->mb_num = h->mb_width * h->mb_height; |
| 1106 | h->mb_stride = h->mb_width + 1; |
| 1107 | |
| 1108 | h->b_stride = h->mb_width * 4; |
| 1109 | |
| 1110 | h->chroma_y_shift = sps->chroma_format_idc <= 1; // 400 uses yuv420p |
| 1111 | |
| 1112 | h->width = 16 * h->mb_width; |
| 1113 | h->height = 16 * h->mb_height; |
| 1114 | |
| 1115 | init_dimensions(h); |
| 1116 |
no test coverage detected