James Almer: > apv_read_header() reads enough information that the generic demux code doesn't > attempt to read a frame to fill missing fields in codecpar, so make sure it's > set here. > > Signed-off-by: James Almer <jamr...@gmail.com> > --- > libavformat/apvdec.c | 40 ++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 38 insertions(+), 2 deletions(-) > > diff --git a/libavformat/apvdec.c b/libavformat/apvdec.c > index e1ac34b003..9f8af35567 100644 > --- a/libavformat/apvdec.c > +++ b/libavformat/apvdec.c > @@ -39,6 +39,11 @@ typedef struct APVHeaderInfo { > uint8_t chroma_format_idc; > uint8_t bit_depth_minus8; > > + uint8_t color_primaries; > + uint8_t transfer_characteristics; > + uint8_t matrix_coefficients; > + uint8_t full_range_flag; > + > enum AVPixelFormat pixel_format; > } APVHeaderInfo; > > @@ -111,6 +116,31 @@ static int apv_extract_header_info(APVHeaderInfo *info, > if (zero != 0) > return AVERROR_INVALIDDATA; > > + // Return if this function was called by apv_probe()
Why do you want to make probing less strict? > + if (bytestream2_get_bytes_left(gbc) == 0) > + return 1; > + > + zero = bytestream2_get_byte(gbc); > + if (zero != 0) > + return AVERROR_INVALIDDATA; > + > + // color_description_present_flag > + if (bytestream2_peek_byte(gbc) >> 7) { > + unsigned color_description; > + > + // We can read 32 bits as tile info is guaranteed to be present > after this. > + color_description = bytestream2_get_be32(gbc); > + info->color_primaries = (color_description >> 23) & 0xff; > + info->transfer_characteristics = (color_description >> 15) & 0xff; > + info->matrix_coefficients = (color_description >> 7) & 0xff; > + info->full_range_flag = (color_description >> 6) & 1; > + } else { > + info->color_primaries = AVCOL_PRI_UNSPECIFIED; > + info->transfer_characteristics = AVCOL_TRC_UNSPECIFIED; > + info->matrix_coefficients = AVCOL_SPC_UNSPECIFIED; > + info->full_range_flag = 0; > + } > + > return 1; > } > > @@ -126,7 +156,7 @@ static int apv_probe(const AVProbeData *p) > return 0; > } > > - bytestream2_init(&gbc, p->buf, p->buf_size); > + bytestream2_init(&gbc, p->buf, 28); > > au_size = bytestream2_get_be32(&gbc); > if (au_size < 24) { > @@ -157,7 +187,7 @@ static int apv_read_header(AVFormatContext *s) > AVStream *st; > GetByteContext gbc; > APVHeaderInfo header; > - uint8_t buffer[28]; > + uint8_t buffer[33]; > uint32_t au_size, signature, pbu_size; > int err, size; > > @@ -201,6 +231,12 @@ static int apv_read_header(AVFormatContext *s) > st->codecpar->level = header.level_idc; > st->codecpar->width = header.frame_width; > st->codecpar->height = header.frame_height; > + st->codecpar->chroma_location = AVCHROMA_LOC_TOPLEFT; > + st->codecpar->color_primaries = header.color_primaries; > + st->codecpar->color_trc = header.transfer_characteristics; > + st->codecpar->color_space = header.matrix_coefficients; > + st->codecpar->color_range = header.full_range_flag ? AVCOL_RANGE_JPEG > + : > AVCOL_RANGE_MPEG; > > st->avg_frame_rate = (AVRational){ 30, 1 }; > avpriv_set_pts_info(st, 64, 1, 30); _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".