mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-02 14:20:06 +00:00
codecparser: vp9: move persistent fields from GstVp9FrameHdr to GstVp9Parser
The subsampling_x, subsampling_y, bit_depth, color_space and color_range fileds are moved from GstVp9FrameHdr to the global GstVp9Parser structure. These fields are only present in keyframe or intra-only frame, no need to duplicate them for inter-frames. This is an ABI change. https://bugzilla.gnome.org/show_bug.cgi?id=764370
This commit is contained in:
parent
78cb53ad3c
commit
88a3b4da3c
2 changed files with 43 additions and 47 deletions
|
@ -103,26 +103,26 @@ verify_sync_code (GstBitReader * const br)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
parse_bitdepth_colorspace_sampling (GstBitReader * const br,
|
||||
GstVp9FrameHdr * frame_hdr)
|
||||
parse_bitdepth_colorspace_sampling (GstVp9Parser * parser,
|
||||
GstBitReader * const br, GstVp9FrameHdr * frame_hdr)
|
||||
{
|
||||
if (frame_hdr->profile > GST_VP9_PROFILE_1)
|
||||
frame_hdr->bit_depth =
|
||||
parser->bit_depth =
|
||||
gst_vp9_read_bit (br) ? GST_VP9_BIT_DEPTH_12 : GST_VP9_BIT_DEPTH_10;
|
||||
else
|
||||
frame_hdr->bit_depth = GST_VP9_BIT_DEPTH_8;
|
||||
parser->bit_depth = GST_VP9_BIT_DEPTH_8;
|
||||
|
||||
frame_hdr->color_space = gst_vp9_read_bits (br, 3);
|
||||
if (frame_hdr->color_space != GST_VP9_CS_SRGB) {
|
||||
frame_hdr->color_range = gst_vp9_read_bit (br);
|
||||
parser->color_space = gst_vp9_read_bits (br, 3);
|
||||
if (parser->color_space != GST_VP9_CS_SRGB) {
|
||||
parser->color_range = gst_vp9_read_bit (br);
|
||||
|
||||
if (frame_hdr->profile == GST_VP9_PROFILE_1
|
||||
|| frame_hdr->profile == GST_VP9_PROFILE_3) {
|
||||
|
||||
frame_hdr->subsampling_x = gst_vp9_read_bit (br);
|
||||
frame_hdr->subsampling_y = gst_vp9_read_bit (br);
|
||||
parser->subsampling_x = gst_vp9_read_bit (br);
|
||||
parser->subsampling_y = gst_vp9_read_bit (br);
|
||||
|
||||
if (frame_hdr->subsampling_x == 1 && frame_hdr->subsampling_y == 1) {
|
||||
if (parser->subsampling_x == 1 && parser->subsampling_y == 1) {
|
||||
GST_ERROR
|
||||
("4:2:0 subsampling is not supported in profile_1 or profile_3");
|
||||
goto error;
|
||||
|
@ -133,10 +133,10 @@ parse_bitdepth_colorspace_sampling (GstBitReader * const br,
|
|||
goto error;
|
||||
}
|
||||
} else {
|
||||
frame_hdr->subsampling_y = frame_hdr->subsampling_x = 1;
|
||||
parser->subsampling_y = parser->subsampling_x = 1;
|
||||
}
|
||||
} else {
|
||||
frame_hdr->color_range = GST_VP9_CR_FULL;
|
||||
parser->color_range = GST_VP9_CR_FULL;
|
||||
|
||||
if (frame_hdr->profile == GST_VP9_PROFILE_1
|
||||
|| frame_hdr->profile == GST_VP9_PROFILE_3) {
|
||||
|
@ -481,12 +481,12 @@ segmentation_update (GstVp9Parser * parser, const GstVp9FrameHdr * frame_hdr)
|
|||
const GstVp9SegmentationInfoData *info = priv->segmentation + i;
|
||||
|
||||
seg->luma_dc_quant_scale =
|
||||
gst_vp9_dc_quant (q, quant_indices->y_dc_delta, frame_hdr->bit_depth);
|
||||
seg->luma_ac_quant_scale = gst_vp9_ac_quant (q, 0, frame_hdr->bit_depth);
|
||||
gst_vp9_dc_quant (q, quant_indices->y_dc_delta, parser->bit_depth);
|
||||
seg->luma_ac_quant_scale = gst_vp9_ac_quant (q, 0, parser->bit_depth);
|
||||
seg->chroma_dc_quant_scale =
|
||||
gst_vp9_dc_quant (q, quant_indices->uv_dc_delta, frame_hdr->bit_depth);
|
||||
gst_vp9_dc_quant (q, quant_indices->uv_dc_delta, parser->bit_depth);
|
||||
seg->chroma_ac_quant_scale =
|
||||
gst_vp9_ac_quant (q, quant_indices->uv_ac_delta, frame_hdr->bit_depth);
|
||||
gst_vp9_ac_quant (q, quant_indices->uv_ac_delta, parser->bit_depth);
|
||||
|
||||
if (lf->filter_level) {
|
||||
guint8 filter = seg_get_filter_level (parser, frame_hdr, i);
|
||||
|
@ -578,13 +578,17 @@ setup_past_independence (GstVp9Parser * parser,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_vp9_parser_init (GstVp9Parser * parser)
|
||||
gst_vp9_parser_reset (GstVp9Parser * parser)
|
||||
{
|
||||
GstVp9ParserPrivate *priv = parser->priv;
|
||||
|
||||
memset (parser, 0, sizeof (GstVp9Parser));
|
||||
memset (priv, 0, sizeof (GstVp9ParserPrivate));
|
||||
parser->priv = NULL;
|
||||
memset (parser->mb_segment_tree_probs, 0,
|
||||
sizeof (parser->mb_segment_tree_probs));
|
||||
memset (parser->segment_pred_probs, 0, sizeof (parser->segment_pred_probs));
|
||||
memset (parser->segmentation, 0, sizeof (parser->segmentation));
|
||||
|
||||
memset (priv, 0, sizeof (GstVp9ParserPrivate));
|
||||
parser->priv = priv;
|
||||
}
|
||||
|
||||
|
@ -592,7 +596,7 @@ static GstVp9ParserResult
|
|||
gst_vp9_parser_update (GstVp9Parser * parser, GstVp9FrameHdr * const frame_hdr)
|
||||
{
|
||||
if (frame_hdr->frame_type == GST_VP9_KEY_FRAME)
|
||||
gst_vp9_parser_init (parser);
|
||||
gst_vp9_parser_reset (parser);
|
||||
|
||||
if (frame_is_intra_only (frame_hdr) || frame_hdr->error_resilient_mode)
|
||||
setup_past_independence (parser, frame_hdr);
|
||||
|
@ -626,16 +630,15 @@ gst_vp9_parser_new (void)
|
|||
INITIALIZE_DEBUG_CATEGORY;
|
||||
GST_DEBUG ("Create VP9 Parser");
|
||||
|
||||
parser = g_slice_new (GstVp9Parser);
|
||||
parser = g_slice_new0 (GstVp9Parser);
|
||||
if (!parser)
|
||||
return NULL;
|
||||
|
||||
priv = g_slice_new (GstVp9ParserPrivate);
|
||||
priv = g_slice_new0 (GstVp9ParserPrivate);
|
||||
if (!priv)
|
||||
return NULL;
|
||||
|
||||
parser->priv = priv;
|
||||
gst_vp9_parser_init (parser);
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
@ -712,7 +715,7 @@ gst_vp9_parser_parse_frame_header (GstVp9Parser * parser,
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (!parse_bitdepth_colorspace_sampling (br, frame_hdr)) {
|
||||
if (!parse_bitdepth_colorspace_sampling (parser, br, frame_hdr)) {
|
||||
GST_ERROR ("Failed to parse color_space/bit_depth info !");
|
||||
goto error;
|
||||
}
|
||||
|
@ -734,15 +737,15 @@ gst_vp9_parser_parse_frame_header (GstVp9Parser * parser,
|
|||
}
|
||||
|
||||
if (frame_hdr->profile > GST_VP9_PROFILE_0) {
|
||||
if (!parse_bitdepth_colorspace_sampling (br, frame_hdr)) {
|
||||
if (!parse_bitdepth_colorspace_sampling (parser, br, frame_hdr)) {
|
||||
GST_ERROR ("Failed to parse color_space/bit_depth info !");
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
frame_hdr->color_space = GST_VP9_CS_BT_601;
|
||||
frame_hdr->color_range = GST_VP9_CR_LIMITED;
|
||||
frame_hdr->subsampling_y = frame_hdr->subsampling_x = 1;
|
||||
frame_hdr->bit_depth = GST_VP9_BIT_DEPTH_8;
|
||||
parser->color_space = GST_VP9_CS_BT_601;
|
||||
parser->color_range = GST_VP9_CR_LIMITED;
|
||||
parser->subsampling_y = parser->subsampling_x = 1;
|
||||
parser->bit_depth = GST_VP9_BIT_DEPTH_8;
|
||||
}
|
||||
|
||||
frame_hdr->refresh_frame_flags =
|
||||
|
@ -766,12 +769,6 @@ gst_vp9_parser_parse_frame_header (GstVp9Parser * parser,
|
|||
|
||||
frame_hdr->allow_high_precision_mv = gst_vp9_read_bit (br);
|
||||
frame_hdr->mcomp_filter_type = parse_interp_filter (br);
|
||||
|
||||
/* Assing defalut values */
|
||||
frame_hdr->color_space = GST_VP9_CS_BT_601;
|
||||
frame_hdr->color_range = GST_VP9_CR_LIMITED;
|
||||
frame_hdr->subsampling_y = frame_hdr->subsampling_x = 1;
|
||||
frame_hdr->bit_depth = GST_VP9_BIT_DEPTH_8;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -811,7 +808,6 @@ gst_vp9_parser_parse_frame_header (GstVp9Parser * parser,
|
|||
|
||||
frame_hdr->frame_header_length_in_bytes =
|
||||
(gst_bit_reader_get_pos (br) + 7) / 8;
|
||||
|
||||
return gst_vp9_parser_update (parser, frame_hdr);
|
||||
|
||||
error:
|
||||
|
|
|
@ -350,17 +350,12 @@ struct _GstVp9SegmentationInfo {
|
|||
* @frame_type: frame type
|
||||
* @show_frame: indicate whether it is a displayable frame or not
|
||||
* @error_resilient_mode: error resilent mode
|
||||
* @subsampling_x: horizontal subsampling
|
||||
* @subsampling_y: vertical subsampling
|
||||
* @width: frame width
|
||||
* @height: frame height
|
||||
* @display_size_enabled: display size enabled (cropping)
|
||||
* @display_width: display width
|
||||
* @display_height: display height
|
||||
* @frame_context_idx: frame context index
|
||||
* @bit_depth: bit depth of the stream
|
||||
* @color_space: color space standard
|
||||
* @color_range: color range standard
|
||||
* @intra_only: intra only frame
|
||||
* @reset_frame_context: reset frame context
|
||||
* @refresh_frame_flags: refresh reference frame flags
|
||||
|
@ -391,8 +386,6 @@ struct _GstVp9FrameHdr
|
|||
guint frame_type;
|
||||
guint8 show_frame;
|
||||
guint8 error_resilient_mode;
|
||||
gint subsampling_x;
|
||||
gint subsampling_y;
|
||||
guint32 width;
|
||||
guint32 height;
|
||||
guint8 display_size_enabled;
|
||||
|
@ -400,10 +393,6 @@ struct _GstVp9FrameHdr
|
|||
guint32 display_height;
|
||||
guint frame_context_idx;
|
||||
|
||||
guint bit_depth;
|
||||
guint color_space;
|
||||
guint color_range;
|
||||
|
||||
guint8 intra_only;
|
||||
gint reset_frame_context;
|
||||
gint refresh_frame_flags;
|
||||
|
@ -464,6 +453,11 @@ struct _GstVp9Segmentation
|
|||
/**
|
||||
* GstVp9Parser:
|
||||
* @priv: GstVp9ParserPrivate struct to keep track of state variables
|
||||
* @subsampling_x: horizontal subsampling
|
||||
* @subsampling_y: vertical subsampling
|
||||
* @bit_depth: bit depth of the stream
|
||||
* @color_space: color space standard
|
||||
* @color_range: color range standard
|
||||
* @mb_segment_tree_probs: decoding tree probabilities
|
||||
* @segment_pred_probs: segment prediction probabiilties
|
||||
* @segmentation: Segmentation info
|
||||
|
@ -477,6 +471,12 @@ struct _GstVp9Parser
|
|||
/* private stuct for tracking state variables across frames */
|
||||
void *priv;
|
||||
|
||||
gint subsampling_x;
|
||||
gint subsampling_y;
|
||||
guint bit_depth;
|
||||
guint color_space;
|
||||
guint color_range;
|
||||
|
||||
guint8 mb_segment_tree_probs[GST_VP9_SEG_TREE_PROBS];
|
||||
guint8 segment_pred_probs[GST_VP9_PREDICTION_PROBS];
|
||||
GstVp9Segmentation segmentation[GST_VP9_MAX_SEGMENTS];
|
||||
|
|
Loading…
Reference in a new issue