You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
h264: decode the poc values from the slice header into the per-slice context
Copy them into the decoder-global context in field_start(). This avoids modifying the decoder-global context during bitstream parsing.
This commit is contained in:
@@ -446,6 +446,11 @@ typedef struct H264SliceContext {
|
|||||||
MMCO mmco[MAX_MMCO_COUNT];
|
MMCO mmco[MAX_MMCO_COUNT];
|
||||||
int nb_mmco;
|
int nb_mmco;
|
||||||
int explicit_ref_marking;
|
int explicit_ref_marking;
|
||||||
|
|
||||||
|
int frame_num;
|
||||||
|
int poc_lsb;
|
||||||
|
int delta_poc_bottom;
|
||||||
|
int delta_poc[2];
|
||||||
} H264SliceContext;
|
} H264SliceContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1009,6 +1009,12 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl,
|
|||||||
h->droppable = (nal->ref_idc == 0);
|
h->droppable = (nal->ref_idc == 0);
|
||||||
h->picture_structure = sl->picture_structure;
|
h->picture_structure = sl->picture_structure;
|
||||||
|
|
||||||
|
h->poc.frame_num = sl->frame_num;
|
||||||
|
h->poc.poc_lsb = sl->poc_lsb;
|
||||||
|
h->poc.delta_poc_bottom = sl->delta_poc_bottom;
|
||||||
|
h->poc.delta_poc[0] = sl->delta_poc[0];
|
||||||
|
h->poc.delta_poc[1] = sl->delta_poc[1];
|
||||||
|
|
||||||
/* Shorten frame num gaps so we don't have to allocate reference
|
/* Shorten frame num gaps so we don't have to allocate reference
|
||||||
* frames just to throw them away */
|
* frames just to throw them away */
|
||||||
if (h->poc.frame_num != h->poc.prev_frame_num) {
|
if (h->poc.frame_num != h->poc.prev_frame_num) {
|
||||||
@@ -1175,7 +1181,7 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl,
|
|||||||
int ret;
|
int ret;
|
||||||
unsigned int slice_type, tmp, i;
|
unsigned int slice_type, tmp, i;
|
||||||
int field_pic_flag, bottom_field_flag;
|
int field_pic_flag, bottom_field_flag;
|
||||||
int frame_num, droppable, picture_structure;
|
int droppable, picture_structure;
|
||||||
|
|
||||||
sl->first_mb_addr = get_ue_golomb(&sl->gb);
|
sl->first_mb_addr = get_ue_golomb(&sl->gb);
|
||||||
|
|
||||||
@@ -1222,9 +1228,7 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl,
|
|||||||
}
|
}
|
||||||
sps = (const SPS*)h->ps.sps_list[pps->sps_id]->data;
|
sps = (const SPS*)h->ps.sps_list[pps->sps_id]->data;
|
||||||
|
|
||||||
frame_num = get_bits(&sl->gb, sps->log2_max_frame_num);
|
sl->frame_num = get_bits(&sl->gb, sps->log2_max_frame_num);
|
||||||
if (!h->setup_finished)
|
|
||||||
h->poc.frame_num = frame_num;
|
|
||||||
|
|
||||||
sl->mb_mbaff = 0;
|
sl->mb_mbaff = 0;
|
||||||
|
|
||||||
@@ -1244,10 +1248,10 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl,
|
|||||||
sl->mb_field_decoding_flag = picture_structure != PICT_FRAME;
|
sl->mb_field_decoding_flag = picture_structure != PICT_FRAME;
|
||||||
|
|
||||||
if (picture_structure == PICT_FRAME) {
|
if (picture_structure == PICT_FRAME) {
|
||||||
h->curr_pic_num = h->poc.frame_num;
|
h->curr_pic_num = sl->frame_num;
|
||||||
h->max_pic_num = 1 << sps->log2_max_frame_num;
|
h->max_pic_num = 1 << sps->log2_max_frame_num;
|
||||||
} else {
|
} else {
|
||||||
h->curr_pic_num = 2 * h->poc.frame_num + 1;
|
h->curr_pic_num = 2 * sl->frame_num + 1;
|
||||||
h->max_pic_num = 1 << (sps->log2_max_frame_num + 1);
|
h->max_pic_num = 1 << (sps->log2_max_frame_num + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1255,30 +1259,17 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl,
|
|||||||
get_ue_golomb(&sl->gb); /* idr_pic_id */
|
get_ue_golomb(&sl->gb); /* idr_pic_id */
|
||||||
|
|
||||||
if (sps->poc_type == 0) {
|
if (sps->poc_type == 0) {
|
||||||
int poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb);
|
sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb);
|
||||||
|
|
||||||
if (!h->setup_finished)
|
if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME)
|
||||||
h->poc.poc_lsb = poc_lsb;
|
sl->delta_poc_bottom = get_se_golomb(&sl->gb);
|
||||||
|
|
||||||
if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) {
|
|
||||||
int delta_poc_bottom = get_se_golomb(&sl->gb);
|
|
||||||
if (!h->setup_finished)
|
|
||||||
h->poc.delta_poc_bottom = delta_poc_bottom;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) {
|
if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) {
|
||||||
int delta_poc = get_se_golomb(&sl->gb);
|
sl->delta_poc[0] = get_se_golomb(&sl->gb);
|
||||||
|
|
||||||
if (!h->setup_finished)
|
if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME)
|
||||||
h->poc.delta_poc[0] = delta_poc;
|
sl->delta_poc[1] = get_se_golomb(&sl->gb);
|
||||||
|
|
||||||
if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) {
|
|
||||||
delta_poc = get_se_golomb(&sl->gb);
|
|
||||||
|
|
||||||
if (!h->setup_finished)
|
|
||||||
h->poc.delta_poc[1] = delta_poc;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pps->redundant_pic_cnt_present)
|
if (pps->redundant_pic_cnt_present)
|
||||||
|
Reference in New Issue
Block a user