mirror of
				https://github.com/nyanmisaka/ffmpeg-rockchip.git
				synced 2025-10-31 12:36:41 +08:00 
			
		
		
		
	hevc_parser: drop the use of SliceHeader
It is only used to store a few local variables within one function, which is better accomplished by just declaring them on stack explicitly.
This commit is contained in:
		| @@ -42,7 +42,6 @@ typedef struct HEVCParserContext { | |||||||
|     H2645Packet pkt; |     H2645Packet pkt; | ||||||
|     HEVCParamSets ps; |     HEVCParamSets ps; | ||||||
|     HEVCSEI sei; |     HEVCSEI sei; | ||||||
|     SliceHeader sh; |  | ||||||
|  |  | ||||||
|     int is_avc; |     int is_avc; | ||||||
|     int nal_length_size; |     int nal_length_size; | ||||||
| @@ -58,26 +57,28 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, | |||||||
|     HEVCParserContext *ctx = s->priv_data; |     HEVCParserContext *ctx = s->priv_data; | ||||||
|     HEVCParamSets *ps = &ctx->ps; |     HEVCParamSets *ps = &ctx->ps; | ||||||
|     HEVCSEI *sei = &ctx->sei; |     HEVCSEI *sei = &ctx->sei; | ||||||
|     SliceHeader *sh = &ctx->sh; |  | ||||||
|     GetBitContext *gb = &nal->gb; |     GetBitContext *gb = &nal->gb; | ||||||
|     const HEVCWindow *ow; |     const HEVCWindow *ow; | ||||||
|     int i, num = 0, den = 0; |     int i, num = 0, den = 0; | ||||||
|  |  | ||||||
|     sh->first_slice_in_pic_flag = get_bits1(gb); |     unsigned int pps_id, first_slice_in_pic_flag, dependent_slice_segment_flag; | ||||||
|  |     enum HEVCSliceType slice_type; | ||||||
|  |  | ||||||
|  |     first_slice_in_pic_flag = get_bits1(gb); | ||||||
|     s->picture_structure = sei->picture_timing.picture_struct; |     s->picture_structure = sei->picture_timing.picture_struct; | ||||||
|     s->field_order = sei->picture_timing.picture_struct; |     s->field_order = sei->picture_timing.picture_struct; | ||||||
|  |  | ||||||
|     if (IS_IRAP_NAL(nal)) { |     if (IS_IRAP_NAL(nal)) { | ||||||
|         s->key_frame = 1; |         s->key_frame = 1; | ||||||
|         sh->no_output_of_prior_pics_flag = get_bits1(gb); |         skip_bits1(gb); // no_output_of_prior_pics_flag | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     sh->pps_id = get_ue_golomb(gb); |     pps_id = get_ue_golomb(gb); | ||||||
|     if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) { |     if (pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[pps_id]) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); |         av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); | ||||||
|         return AVERROR_INVALIDDATA; |         return AVERROR_INVALIDDATA; | ||||||
|     } |     } | ||||||
|     ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data; |     ps->pps = (HEVCPPS*)ps->pps_list[pps_id]->data; | ||||||
|  |  | ||||||
|     if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) { |     if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id); |         av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id); | ||||||
| @@ -109,51 +110,53 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, | |||||||
|         av_reduce(&avctx->framerate.den, &avctx->framerate.num, |         av_reduce(&avctx->framerate.den, &avctx->framerate.num, | ||||||
|                   num, den, 1 << 30); |                   num, den, 1 << 30); | ||||||
|  |  | ||||||
|     if (!sh->first_slice_in_pic_flag) { |     if (!first_slice_in_pic_flag) { | ||||||
|  |         unsigned int slice_segment_addr; | ||||||
|         int slice_address_length; |         int slice_address_length; | ||||||
|  |  | ||||||
|         if (ps->pps->dependent_slice_segments_enabled_flag) |         if (ps->pps->dependent_slice_segments_enabled_flag) | ||||||
|             sh->dependent_slice_segment_flag = get_bits1(gb); |             dependent_slice_segment_flag = get_bits1(gb); | ||||||
|         else |         else | ||||||
|             sh->dependent_slice_segment_flag = 0; |             dependent_slice_segment_flag = 0; | ||||||
|  |  | ||||||
|         slice_address_length = av_ceil_log2_c(ps->sps->ctb_width * |         slice_address_length = av_ceil_log2_c(ps->sps->ctb_width * | ||||||
|                                               ps->sps->ctb_height); |                                               ps->sps->ctb_height); | ||||||
|         sh->slice_segment_addr = get_bitsz(gb, slice_address_length); |         slice_segment_addr = get_bitsz(gb, slice_address_length); | ||||||
|         if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) { |         if (slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) { | ||||||
|             av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", |             av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", | ||||||
|                    sh->slice_segment_addr); |                    slice_segment_addr); | ||||||
|             return AVERROR_INVALIDDATA; |             return AVERROR_INVALIDDATA; | ||||||
|         } |         } | ||||||
|     } else |     } else | ||||||
|         sh->dependent_slice_segment_flag = 0; |         dependent_slice_segment_flag = 0; | ||||||
|  |  | ||||||
|     if (sh->dependent_slice_segment_flag) |     if (dependent_slice_segment_flag) | ||||||
|         return 0; /* break; */ |         return 0; /* break; */ | ||||||
|  |  | ||||||
|     for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++) |     for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++) | ||||||
|         skip_bits(gb, 1); // slice_reserved_undetermined_flag[] |         skip_bits(gb, 1); // slice_reserved_undetermined_flag[] | ||||||
|  |  | ||||||
|     sh->slice_type = get_ue_golomb(gb); |     slice_type = get_ue_golomb(gb); | ||||||
|     if (!(sh->slice_type == HEVC_SLICE_I || sh->slice_type == HEVC_SLICE_P || |     if (!(slice_type == HEVC_SLICE_I || slice_type == HEVC_SLICE_P || | ||||||
|           sh->slice_type == HEVC_SLICE_B)) { |           slice_type == HEVC_SLICE_B)) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n", |         av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n", | ||||||
|                sh->slice_type); |                slice_type); | ||||||
|         return AVERROR_INVALIDDATA; |         return AVERROR_INVALIDDATA; | ||||||
|     } |     } | ||||||
|     s->pict_type = sh->slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B : |     s->pict_type = slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B : | ||||||
|                    sh->slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P : |                    slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P : | ||||||
|                                                 AV_PICTURE_TYPE_I; |                                                 AV_PICTURE_TYPE_I; | ||||||
|  |  | ||||||
|     if (ps->pps->output_flag_present_flag) |     if (ps->pps->output_flag_present_flag) | ||||||
|         sh->pic_output_flag = get_bits1(gb); |         skip_bits1(gb); // pic_output_flag | ||||||
|  |  | ||||||
|     if (ps->sps->separate_colour_plane_flag) |     if (ps->sps->separate_colour_plane_flag) | ||||||
|         sh->colour_plane_id = get_bits(gb, 2); |         skip_bits(gb, 2);   // colour_plane_id | ||||||
|  |  | ||||||
|     if (!IS_IDR_NAL(nal)) { |     if (!IS_IDR_NAL(nal)) { | ||||||
|         sh->pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb); |         int pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb); | ||||||
|         s->output_picture_number = ctx->poc = ff_hevc_compute_poc(ps->sps, ctx->pocTid0, sh->pic_order_cnt_lsb, nal->type); |         s->output_picture_number = ctx->poc = | ||||||
|  |             ff_hevc_compute_poc(ps->sps, ctx->pocTid0, pic_order_cnt_lsb, nal->type); | ||||||
|     } else |     } else | ||||||
|         s->output_picture_number = ctx->poc = 0; |         s->output_picture_number = ctx->poc = 0; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Anton Khirnov
					Anton Khirnov