FFmpeg
evc_parse.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /**
20  * @file
21  * EVC decoder/parser shared code
22  */
23 
24 #ifndef AVCODEC_EVC_PARSE_H
25 #define AVCODEC_EVC_PARSE_H
26 
27 #include <stdint.h>
28 
29 #include "libavutil/intreadwrite.h"
30 #include "libavutil/log.h"
31 #include "evc.h"
32 #include "evc_ps.h"
33 
34 // The sturcture reflects Slice Header RBSP(raw byte sequence payload) layout
35 // @see ISO_IEC_23094-1 section 7.3.2.6
36 //
37 // The following descriptors specify the parsing process of each element
38 // u(n) - unsigned integer using n bits
39 // ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first
40 // u(n) - unsigned integer using n bits.
41 // When n is "v" in the syntax table, the number of bits varies in a manner dependent on the value of other syntax elements.
42 typedef struct EVCParserSliceHeader {
43  uint8_t slice_pic_parameter_set_id; // ue(v)
44  uint8_t single_tile_in_slice_flag; // u(1)
45  uint8_t first_tile_id; // u(v)
46  uint8_t arbitrary_slice_flag; // u(1)
47  uint8_t last_tile_id; // u(v)
50 
51  uint8_t slice_type; // ue(v)
53  uint8_t mmvd_group_enable_flag; // u(1)
54  uint8_t slice_alf_enabled_flag; // u(1)
55 
56  uint8_t slice_alf_luma_aps_id; // u(5)
57  uint8_t slice_alf_map_flag; // u(1)
58  uint8_t slice_alf_chroma_idc; // u(2)
59  uint8_t slice_alf_chroma_aps_id; // u(5)
60  uint8_t slice_alf_chroma_map_flag; // u(1)
61  uint8_t slice_alf_chroma2_aps_id; // u(5)
62  uint8_t slice_alf_chroma2_map_flag; // u(1)
63  uint16_t slice_pic_order_cnt_lsb; // u(v)
64 
65  // @note
66  // Currently the structure does not reflect the entire Slice Header RBSP layout.
67  // It contains only the fields that are necessary to read from the NAL unit all the values
68  // necessary for the correct initialization of the AVCodecContext structure.
69 
70  // @note
71  // If necessary, add the missing fields to the structure to reflect
72  // the contents of the entire NAL unit of the SPS type
73 
75 
76 // picture order count of the current picture
77 typedef struct EVCParserPoc {
78  int PicOrderCntVal; // current picture order count value
79  int prevPicOrderCntVal; // the picture order count of the previous Tid0 picture
80  int DocOffset; // the decoding order count of the previous picture
81 } EVCParserPoc;
82 
83 static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_size, void *logctx)
84 {
85  uint32_t nalu_len = 0;
86 
88  av_log(logctx, AV_LOG_ERROR, "Can't read NAL unit length\n");
89  return 0;
90  }
91 
92  nalu_len = AV_RB32(bits);
93 
94  return nalu_len;
95 }
96 
98  const EVCParamSets *ps, enum EVCNALUnitType nalu_type);
99 
100 // POC (picture order count of the current picture) derivation
101 // @see ISO/IEC 23094-1:2020(E) 8.3.1 Decoding process for picture order count
102 int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh,
103  EVCParserPoc *poc, enum EVCNALUnitType nalu_type, int tid);
104 
105 #endif /* AVCODEC_EVC_PARSE_H */
EVCParserPoc::PicOrderCntVal
int PicOrderCntVal
Definition: evc_parse.h:78
EVCParserSliceHeader::single_tile_in_slice_flag
uint8_t single_tile_in_slice_flag
Definition: evc_parse.h:44
EVCParamSets
Definition: evc_ps.h:211
EVC_MAX_TILE_COLUMNS
@ EVC_MAX_TILE_COLUMNS
Definition: evc.h:140
evc_ps.h
EVCParserSliceHeader::slice_alf_luma_aps_id
uint8_t slice_alf_luma_aps_id
Definition: evc_parse.h:56
EVC_MAX_TILE_ROWS
@ EVC_MAX_TILE_ROWS
Definition: evc.h:138
GetBitContext
Definition: get_bits.h:108
EVCParserPoc::DocOffset
int DocOffset
Definition: evc_parse.h:80
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
EVCParserSliceHeader::no_output_of_prior_pics_flag
uint8_t no_output_of_prior_pics_flag
Definition: evc_parse.h:52
EVCParserSliceHeader::slice_pic_order_cnt_lsb
uint16_t slice_pic_order_cnt_lsb
Definition: evc_parse.h:63
intreadwrite.h
bits
uint8_t bits
Definition: vp3data.h:128
EVCParserSliceHeader::slice_alf_chroma2_map_flag
uint8_t slice_alf_chroma2_map_flag
Definition: evc_parse.h:62
ff_evc_parse_slice_header
int ff_evc_parse_slice_header(GetBitContext *gb, EVCParserSliceHeader *sh, const EVCParamSets *ps, enum EVCNALUnitType nalu_type)
Definition: evc_parse.c:24
EVCParserSliceHeader::slice_alf_enabled_flag
uint8_t slice_alf_enabled_flag
Definition: evc_parse.h:54
EVCParserSliceHeader::slice_alf_map_flag
uint8_t slice_alf_map_flag
Definition: evc_parse.h:57
EVCParserSliceHeader::last_tile_id
uint8_t last_tile_id
Definition: evc_parse.h:47
EVCParserSliceHeader::slice_type
uint8_t slice_type
Definition: evc_parse.h:51
EVCParserSliceHeader::slice_pic_parameter_set_id
uint8_t slice_pic_parameter_set_id
Definition: evc_parse.h:43
EVCParserSliceHeader
Definition: evc_parse.h:42
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:96
EVCNALUnitType
EVCNALUnitType
Definition: evc.h:33
EVCParserSliceHeader::slice_alf_chroma_idc
uint8_t slice_alf_chroma_idc
Definition: evc_parse.h:58
EVCParserSliceHeader::arbitrary_slice_flag
uint8_t arbitrary_slice_flag
Definition: evc_parse.h:46
EVC_NALU_LENGTH_PREFIX_SIZE
#define EVC_NALU_LENGTH_PREFIX_SIZE
Definition: evc.h:26
EVCParserSliceHeader::first_tile_id
uint8_t first_tile_id
Definition: evc_parse.h:45
log.h
EVCParserSliceHeader::num_remaining_tiles_in_slice_minus1
uint32_t num_remaining_tiles_in_slice_minus1
Definition: evc_parse.h:48
EVCParserSliceHeader::slice_alf_chroma_map_flag
uint8_t slice_alf_chroma_map_flag
Definition: evc_parse.h:60
EVCParserSliceHeader::mmvd_group_enable_flag
uint8_t mmvd_group_enable_flag
Definition: evc_parse.h:53
EVCParserPoc::prevPicOrderCntVal
int prevPicOrderCntVal
Definition: evc_parse.h:79
bits_size
#define bits_size
Definition: bitstream.h:113
evc_read_nal_unit_length
static uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_size, void *logctx)
Definition: evc_parse.h:83
EVCParserSliceHeader::slice_alf_chroma_aps_id
uint8_t slice_alf_chroma_aps_id
Definition: evc_parse.h:59
EVCParserSliceHeader::delta_tile_id_minus1
uint16_t delta_tile_id_minus1[EVC_MAX_TILE_ROWS *EVC_MAX_TILE_COLUMNS]
Definition: evc_parse.h:49
EVCParserPoc
Definition: evc_parse.h:77
evc.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_evc_derive_poc
int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, EVCParserPoc *poc, enum EVCNALUnitType nalu_type, int tid)
Definition: evc_parse.c:140
EVCParserSliceHeader::slice_alf_chroma2_aps_id
uint8_t slice_alf_chroma2_aps_id
Definition: evc_parse.h:61