-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support SEI - Mainly for Film Grain and Field Frame #257
base: up
Are you sure you want to change the base?
Conversation
9205eea
to
4024167
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the patch.
libavcodec/cbs_h266.h
Outdated
@@ -862,6 +862,14 @@ typedef struct CodedBitstreamH266Context { | |||
H266RawVPS *vps[VVC_MAX_VPS_COUNT]; ///< RefStruct references | |||
H266RawSPS *sps[VVC_MAX_SPS_COUNT]; ///< RefStruct references | |||
H266RawPPS *pps[VVC_MAX_PPS_COUNT]; ///< RefStruct references | |||
|
|||
// The currently active parameter sets. These are updated when any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vvc spec did not define the active parameter set.
the parameter set will be active by the H266RawPictureHeader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Will check that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Remove it and move the film grain to the h274 sei syntax template also.
libavcodec/cbs_h266.h
Outdated
@@ -848,6 +848,27 @@ typedef struct H266RawSlice { | |||
int data_bit_start; | |||
} H266RawSlice; | |||
|
|||
typedef struct H266RawSEIFilmGrainCharacteristics { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we reuse AVFilmGrainH274Params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better not to use here. It's used to align for h264/h265/h266 syntax_template.
libavcodec/vvc/sei.h
Outdated
@@ -31,8 +31,19 @@ | |||
#include "libavcodec/sei.h" | |||
#include "libavcodec/vvc.h" | |||
|
|||
typedef struct VVCSEIPictureHash { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we define this in h274.h? and follow film grain things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, but film grain is exposed to the API user with the AV prefix. It's used to align with hevc/sei.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the vvc sei defined in h274, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Will do.
libavcodec/cbs.c
Outdated
@@ -158,7 +158,7 @@ av_cold void ff_cbs_close(CodedBitstreamContext **ctx_ptr) | |||
av_freep(ctx_ptr); | |||
} | |||
|
|||
static void cbs_unit_uninit(CodedBitstreamUnit *unit) | |||
void ff_cbs_unit_uninit(CodedBitstreamUnit *unit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this? better give some explain on the commit log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be better to change it to ff_cbs_unref_unit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, why we need to expose this to public.
can we just take a reference to unit->content_ref, like slice_start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goot catch. I use the same way to add a reference to the unit content_ref and remove the redundant commit for exposing ref unit.
libavcodec/vvc/sei.h
Outdated
typedef struct VVCSEI { | ||
H2645SEI common; | ||
VVCSEIPictureHash picture_hash; | ||
VVCSEIFrameFieldInfo frame_field_info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be defined in h274.h too, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Update VVCSET to H274SEI and move to h274.h
…istics Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
bc2d955
to
69a02c9
Compare
Should we also move to verify picture hash to ff_h274_verify_decoded_picture_hash like ff_h274_apply_film_grain? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the patch.
comment inline
libavcodec/vvc/sei.h
Outdated
#include "libavcodec/h274.h" | ||
|
||
typedef struct VVCSEI { | ||
H2645SEI common; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong indent??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. It is a tab and replace it with spaces.
h->comp_model_present_flag[c] = s->fg_comp_model_present_flag[c]; | ||
|
||
for (int c = 0; c < 3; c++) { | ||
if (h->comp_model_present_flag[c]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we combine the previous with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sure. Good point.
flags(fg_comp_model_present_flag[c], 1, c); | ||
|
||
for (c = 0; c < 3; c++) { | ||
if (current->fg_comp_model_present_flag[c]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about:
const int bd = (c ? current->fg_bit_depth_chroma_minus8 ? current->fg_bit_depth_luma_minus8) + 8;
const int min = 0 - current->fg_model_id * (1 << (bd - 1));
const int max =((1 << bd) - 1) - current->fg_model_id * (1 << (bd - 1))
flag(ffi_top_field_first_flag); | ||
u(8, ffi_display_elemental_periods_minus1, 0, 0xff); | ||
} | ||
u(2, ffi_source_scan_type, 0, 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ub(2, ffi_source_scan_type); ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The range of ffi_source_scan_type is from 0~3. Shouldn't we add it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do two bits mean it ranges from 0~3
SEI_MESSAGE_RW(sei, film_grain_characteristics), | ||
}, | ||
{ | ||
SEI_TYPE_DISPLAY_ORIENTATION, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not included in h274, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it is. See 8.25 Display orientation SEI message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8.25? not in vvc spec, right
@@ -623,6 +665,10 @@ static av_cold int frame_context_init(VVCFrameContext *fc, AVCodecContext *avctx | |||
fc->DPB[j].frame = av_frame_alloc(); | |||
if (!fc->DPB[j].frame) | |||
return AVERROR(ENOMEM); | |||
|
|||
fc->DPB[j].frame_grain = av_frame_alloc(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DPB is not a good place for frame_grain. frame_grain is not included in dpb process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reference it from hevcdec.
for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
ff_hevc_unref_frame(&s->DPB[i], ~0);
av_frame_free(&s->DPB[i].frame_grain);
}
May you help check where is a better place to put on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me try, how to test frame_grain?
libavcodec/vvc/dec.c
Outdated
@@ -887,16 +999,192 @@ static int set_output_format(const VVCContext *s, const AVFrame *output) | |||
return 0; | |||
} | |||
|
|||
static int verify_md5(VVCContext *s, VVCFrameContext *fc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can move this to h274.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! Moved.
libavcodec/vvc/sei.c
Outdated
#include "sei.h" | ||
#include "dec.h" | ||
|
||
static int decode_film_grain_characteristics(const VVCFrameContext *fc, H2645SEIFilmGrainCharacteristics *h, void *payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needed by all h274 users, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs a valid sps, so it's better to keep it for codec specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about put
luma_bit_depth, chroma_bit_depth, vui_full_range_flag, vui_colour_primaries, vui_transfer_characteristics, vui_matrix_coeffs in params list
|
||
if (fc->ref->needs_fg) { | ||
av_assert0(fc->ref->frame_grain->buf[0]); | ||
fgp = av_film_grain_params_select(fc->ref->frame); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fgp can be NULL,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. It is checked check_film_grain.
if (fc->ref->needs_fg &&
(fc->sei.common.film_grain_characteristics.present &&
!ff_h274_film_grain_params_supported(fc->sei.common.film_grain_characteristics.model_id,
fc->ref->frame->format) ||
!av_film_grain_params_select(fc->ref->frame))) {
av_log_once(s->avctx, AV_LOG_WARNING, AV_LOG_DEBUG, &s->film_grain_warning_shown,
"Unsupported film grain parameters. Ignoring film grain.\n");
fc->ref->needs_fg = 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but not in this function, right?
if (!ret) | ||
*got_output = 1; | ||
if (!ret) { | ||
ret = frame_end(s, delayed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to call it export_sei and move it to " if (delayed->output_frame->buf[0] && output) {"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not. We already have a function set_side_data
for export sei.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried add it to if (delayed->output_frame->buf[0] && output) {
at my first version but it doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you have a check?
Yes, if a function is needed by all H.274 users, we should move it to h274.c |
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
passed files: FIELD_A_Panasonic_4.bit FIELD_B_Panasonic_2.bit Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
The type of data of AVBufferRef is uint8_t * and the name can be various types of pointer, so cast it to void * before the assignment to silence the compiling warning. Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
The sei parsing doesn't influent the decoding, so skip the corrupt sei. The buffering period SEI of the following clip also failed to parse on VVCSoftware_VTM: https://www.itu.int/wftp3/av-arch/jvet-site/bitstream_exchange/VVC/under_test/VTM-15.0/HRD_B_Fujitsu_2.zip Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Buffering Period SEI message will be used by other SEI messages like Picture Timing and DU information. Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
…ms_present_flag Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
use
-vf tinterlace
filter to generate the same yuv as VTMpassed files:
FIELD_A_Panasonic_4.bit
FIELD_B_Panasonic_2.bit
VVCSoftware_VTM
FFmpeg