Go to the documentation of this file.
   36                               const char *
name, 
const int *subscripts,
 
   38                               uint32_t range_min, uint32_t range_max)
 
   40     uint32_t leading_bits, 
value;
 
   41     int max_length, leading_zeroes;
 
   48     if (leading_bits == 0) {
 
   49         if (max_length >= 32) {
 
   51                    "%s: more than 31 zeroes.\n", 
name);
 
   55                    "%s: bitstream ended.\n", 
name);
 
   60     leading_zeroes = max_length - 1 - 
av_log2(leading_bits);
 
   65                "%s: bitstream ended.\n", 
name);
 
   73     if (value < range_min || value > range_max) {
 
   75                "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
 
   85                               const char *
name, 
const int *subscripts,
 
   89     uint32_t leading_bits, unsigned_value;
 
   90     int max_length, leading_zeroes;
 
   98     if (leading_bits == 0) {
 
   99         if (max_length >= 32) {
 
  101                    "%s: more than 31 zeroes.\n", 
name);
 
  105                    "%s: bitstream ended.\n", 
name);
 
  110     leading_zeroes = max_length - 1 - 
av_log2(leading_bits);
 
  115                "%s: bitstream ended.\n", 
name);
 
  121     if (unsigned_value & 1)
 
  124         value = unsigned_value / 2;
 
  128     if (value < range_min || value > range_max) {
 
  130                "%"PRId32
", but must be in [%"PRId32
",%"PRId32
"].\n",
 
  140                                const char *
name, 
const int *subscripts,
 
  142                                uint32_t range_min, uint32_t range_max)
 
  148     if (value < range_min || value > range_max) {
 
  150                "%"PRIu32
", but must be in [%"PRIu32
",%"PRIu32
"].\n",
 
  172                                const char *
name, 
const int *subscripts,
 
  181     if (value < range_min || value > range_max) {
 
  183                "%"PRId32
", but must be in [%"PRId32
",%"PRId32
"].\n",
 
  192         uvalue = 2 * (uint32_t)
value - 1;
 
  194         uvalue = 2 * (uint32_t)-
value;
 
  216     int bits_left = payload_size * 8 - cur_pos;
 
  221 #define HEADER(name) do { \ 
  222         ff_cbs_trace_header(ctx, name); \ 
  225 #define CHECK(call) do { \ 
  231 #define FUNC_NAME2(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name 
  232 #define FUNC_NAME1(rw, codec, name) FUNC_NAME2(rw, codec, name) 
  233 #define FUNC_H264(name) FUNC_NAME1(READWRITE, h264, name) 
  234 #define FUNC_H265(name) FUNC_NAME1(READWRITE, h265, name) 
  235 #define FUNC_H266(name) FUNC_NAME1(READWRITE, h266, name) 
  236 #define FUNC_SEI(name)  FUNC_NAME1(READWRITE, sei,  name) 
  238 #define SEI_FUNC(name, args) \ 
  239 static int FUNC(name) args;  \ 
  240 static int FUNC(name ## _internal)(CodedBitstreamContext *ctx, \ 
  241                                    RWContext *rw, void *cur,   \ 
  242                                    SEIMessageState *state)     \ 
  244     return FUNC(name)(ctx, rw, cur, state); \ 
  246 static int FUNC(name) args 
  248 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) 
  250 #define u(width, name, range_min, range_max) \ 
  251         xu(width, name, current->name, range_min, range_max, 0, ) 
  252 #define flag(name) ub(1, name) 
  253 #define ue(name, range_min, range_max) \ 
  254         xue(name, current->name, range_min, range_max, 0, ) 
  255 #define i(width, name, range_min, range_max) \ 
  256         xi(width, name, current->name, range_min, range_max, 0, ) 
  257 #define ib(width, name) \ 
  258         xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), 0, ) 
  259 #define se(name, range_min, range_max) \ 
  260         xse(name, current->name, range_min, range_max, 0, ) 
  262 #define us(width, name, range_min, range_max, subs, ...) \ 
  263         xu(width, name, current->name, range_min, range_max, subs, __VA_ARGS__) 
  264 #define ubs(width, name, subs, ...) \ 
  265         xu(width, name, current->name, 0, MAX_UINT_BITS(width), subs, __VA_ARGS__) 
  266 #define flags(name, subs, ...) \ 
  267         xu(1, name, current->name, 0, 1, subs, __VA_ARGS__) 
  268 #define ues(name, range_min, range_max, subs, ...) \ 
  269         xue(name, current->name, range_min, range_max, subs, __VA_ARGS__) 
  270 #define is(width, name, range_min, range_max, subs, ...) \ 
  271         xi(width, name, current->name, range_min, range_max, subs, __VA_ARGS__) 
  272 #define ibs(width, name, subs, ...) \ 
  273         xi(width, name, current->name, MIN_INT_BITS(width), MAX_INT_BITS(width), subs, __VA_ARGS__) 
  274 #define ses(name, range_min, range_max, subs, ...) \ 
  275         xse(name, current->name, range_min, range_max, subs, __VA_ARGS__) 
  277 #define fixed(width, name, value) do { \ 
  278         av_unused uint32_t fixed_value = value; \ 
  279         xu(width, name, fixed_value, value, value, 0, ); \ 
  284 #define READWRITE read 
  285 #define RWContext GetBitContext 
  287 #define ub(width, name) do { \ 
  289         CHECK(ff_cbs_read_simple_unsigned(ctx, rw, width, #name, \ 
  291         current->name = value; \ 
  293 #define xu(width, name, var, range_min, range_max, subs, ...) do { \ 
  295         CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \ 
  296                                    SUBSCRIPTS(subs, __VA_ARGS__), \ 
  297                                    &value, range_min, range_max)); \ 
  300 #define xue(name, var, range_min, range_max, subs, ...) do { \ 
  302         CHECK(cbs_read_ue_golomb(ctx, rw, #name, \ 
  303                                  SUBSCRIPTS(subs, __VA_ARGS__), \ 
  304                                  &value, range_min, range_max)); \ 
  307 #define xi(width, name, var, range_min, range_max, subs, ...) do { \ 
  309         CHECK(ff_cbs_read_signed(ctx, rw, width, #name, \ 
  310                                  SUBSCRIPTS(subs, __VA_ARGS__), \ 
  311                                  &value, range_min, range_max)); \ 
  314 #define xse(name, var, range_min, range_max, subs, ...) do { \ 
  316         CHECK(cbs_read_se_golomb(ctx, rw, #name, \ 
  317                                  SUBSCRIPTS(subs, __VA_ARGS__), \ 
  318                                  &value, range_min, range_max)); \ 
  323 #define infer(name, value) do { \ 
  324         current->name = value; \ 
  339 #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw)) 
  341 #define bit_position(rw)   (get_bits_count(rw)) 
  342 #define byte_alignment(rw) (get_bits_count(rw) % 8) 
  346 #define allocate(name, size) do { \ 
  347         name  = ff_refstruct_allocz(size + \ 
  348                                         AV_INPUT_BUFFER_PADDING_SIZE); \ 
  350             return AVERROR(ENOMEM); \ 
  353 #define FUNC(name) FUNC_SEI(name) 
  361 #define allocate(name, size) do { \ 
  362         name ## _ref = av_buffer_allocz(size + \ 
  363                                         AV_INPUT_BUFFER_PADDING_SIZE); \ 
  365             return AVERROR(ENOMEM); \ 
  366         name = name ## _ref->data; \ 
  369 #define FUNC(name) FUNC_H264(name) 
  373 #define FUNC(name) FUNC_H265(name) 
  377 #define FUNC(name) FUNC_H266(name) 
  390 #undef more_rbsp_data 
  392 #undef byte_alignment 
  397 #define READWRITE write 
  398 #define RWContext PutBitContext 
  400 #define ub(width, name) do { \ 
  401         uint32_t value = current->name; \ 
  402         CHECK(ff_cbs_write_simple_unsigned(ctx, rw, width, #name, \ 
  405 #define xu(width, name, var, range_min, range_max, subs, ...) do { \ 
  406         uint32_t value = var; \ 
  407         CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \ 
  408                                     SUBSCRIPTS(subs, __VA_ARGS__), \ 
  409                                     value, range_min, range_max)); \ 
  411 #define xue(name, var, range_min, range_max, subs, ...) do { \ 
  412         uint32_t value = var; \ 
  413         CHECK(cbs_write_ue_golomb(ctx, rw, #name, \ 
  414                                   SUBSCRIPTS(subs, __VA_ARGS__), \ 
  415                                   value, range_min, range_max)); \ 
  417 #define xi(width, name, var, range_min, range_max, subs, ...) do { \ 
  418         int32_t value = var; \ 
  419         CHECK(ff_cbs_write_signed(ctx, rw, width, #name, \ 
  420                                   SUBSCRIPTS(subs, __VA_ARGS__), \ 
  421                                   value, range_min, range_max)); \ 
  423 #define xse(name, var, range_min, range_max, subs, ...) do { \ 
  424         int32_t value = var; \ 
  425         CHECK(cbs_write_se_golomb(ctx, rw, #name, \ 
  426                                   SUBSCRIPTS(subs, __VA_ARGS__), \ 
  427                                   value, range_min, range_max)); \ 
  430 #define infer(name, value) do { \ 
  431         if (current->name != (value)) { \ 
  432             av_log(ctx->log_ctx, AV_LOG_ERROR, \ 
  433                    "%s does not match inferred value: " \ 
  434                    "%"PRId64", but should be %"PRId64".\n", \ 
  435                    #name, (int64_t)current->name, (int64_t)(value)); \ 
  436             return AVERROR_INVALIDDATA; \ 
  440 #define more_rbsp_data(var) (var) 
  442 #define bit_position(rw)   (put_bits_count(rw)) 
  443 #define byte_alignment(rw) (put_bits_count(rw) % 8) 
  445 #define allocate(name, size) do { \ 
  447             av_log(ctx->log_ctx, AV_LOG_ERROR, "%s must be set " \ 
  448                    "for writing.\n", #name); \ 
  449             return AVERROR_INVALIDDATA; \ 
  453 #define FUNC(name) FUNC_SEI(name) 
  457 #define FUNC(name) FUNC_H264(name) 
  461 #define FUNC(name) FUNC_H265(name) 
  465 #define FUNC(name) FUNC_H266(name) 
  483 #undef more_rbsp_data 
  485 #undef byte_alignment 
  513                                            : 
packet->rbsp.rbsp_buffer_ref;
 
  539         size_t size, start, end;
 
  549         version = bytestream2_get_byte(&gbc);
 
  560         count = bytestream2_get_byte(&gbc) & 0x1f;
 
  562         for (
i = 0; 
i < count; 
i++) {
 
  565             size = bytestream2_get_be16(&gbc);
 
  573                                     frag->
data + start, end - start,
 
  584         count = bytestream2_get_byte(&gbc);
 
  586         for (
i = 0; 
i < count; 
i++) {
 
  589             size = bytestream2_get_be16(&gbc);
 
  597                                     frag->
data + start, end - start,
 
  614         size_t size, start, end;
 
  615         int i, j, nb_arrays, nal_unit_type, nb_nals, 
version;
 
  624         version = bytestream2_get_byte(&gbc);
 
  634         nb_arrays = bytestream2_get_byte(&gbc);
 
  635         for (
i = 0; 
i < nb_arrays; 
i++) {
 
  636             nal_unit_type = bytestream2_get_byte(&gbc) & 0x3f;
 
  637             nb_nals = bytestream2_get_be16(&gbc);
 
  640             for (j = 0; j < nb_nals; j++) {
 
  643                 size = bytestream2_get_be16(&gbc);
 
  651                                         frag->
data + start, end - start,
 
  655                        "HVCC array %d (%d NAL units of type %d).\n",
 
  656                        i, nb_nals, nal_unit_type);
 
  666         int ptl_present_flag, num_arrays;
 
  673         b = bytestream2_get_byte(&gbc);
 
  675         ptl_present_flag = 
b & 1;
 
  677         if(ptl_present_flag) {
 
  678             int num_sublayers, num_bytes_constraint_info, num_sub_profiles;
 
  679             num_sublayers = (bytestream2_get_be16u(&gbc) >> 4) & 7;
 
  683             num_bytes_constraint_info = bytestream2_get_byte(&gbc) & 0x3f;
 
  685             if(num_sublayers > 1) {
 
  686                 int count_present_flags = 0;
 
  687                 b = bytestream2_get_byte(&gbc);
 
  688                 for(
i = num_sublayers - 2; 
i >= 0; 
i--) {
 
  689                     if((
b >> (7 - (num_sublayers - 2 - 
i))) & 0x01)
 
  690                         count_present_flags++;
 
  694             num_sub_profiles = bytestream2_get_byte(&gbc);
 
  701         num_arrays = bytestream2_get_byte(&gbc);
 
  702         for(j = 0; j < num_arrays; j++) {
 
  703             size_t start, end, 
size;
 
  704             int nal_unit_type = bytestream2_get_byte(&gbc) & 0x1f;
 
  705             unsigned int num_nalus = 1;
 
  707                 num_nalus = bytestream2_get_be16(&gbc);
 
  710             for(
i = 0; 
i < num_nalus; 
i++) {
 
  713                 size = bytestream2_get_be16(&gbc);
 
  721                                         frag->
data + start, end - start,
 
  725                        "VVCC array %d (%d NAL units of type %d).\n",
 
  726                        i, num_nalus, nal_unit_type);
 
  752 #define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element) \ 
  753 static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \ 
  754                                                   CodedBitstreamUnit *unit)  \ 
  756     CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \ 
  757     H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \ 
  758     unsigned int id = ps_var->id_element; \ 
  759     int err = ff_cbs_make_unit_refcounted(ctx, unit); \ 
  762     if (priv->ps_var[id] == priv->active_ ## ps_var) \ 
  763         priv->active_ ## ps_var = NULL ; \ 
  764     av_assert0(unit->content_ref); \ 
  765     ff_refstruct_replace(&priv->ps_var[id], unit->content_ref); \ 
  775 #define cbs_h266_replace_ps(h26n, ps_name, ps_var, id_element) \ 
  776 static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \ 
  777                                                   CodedBitstreamUnit *unit)  \ 
  779     CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \ 
  780     H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \ 
  781     unsigned int id = ps_var->id_element; \ 
  782     int err = ff_cbs_make_unit_refcounted(ctx, unit); \ 
  785     av_assert0(unit->content_ref); \ 
  786     ff_refstruct_replace(&priv->ps_var[id], unit->content_ref); \ 
  824     switch (unit->
type) {
 
  829             err = cbs_h264_read_sps(
ctx, &gbc, 
sps);
 
  833             err = cbs_h264_replace_sps(
ctx, unit);
 
  841             err = cbs_h264_read_sps_extension(
ctx, &gbc, unit->
content);
 
  851             err = cbs_h264_read_pps(
ctx, &gbc, 
pps);
 
  855             err = cbs_h264_replace_pps(
ctx, unit);
 
  868             err = cbs_h264_read_slice_header(
ctx, &gbc, &slice->
header);
 
  889             err = cbs_h264_read_aud(
ctx, &gbc, unit->
content);
 
  897             err = cbs_h264_read_sei(
ctx, &gbc, unit->
content);
 
  905             err = cbs_h264_read_filler(
ctx, &gbc, unit->
content);
 
  915                    cbs_h264_read_end_of_sequence :
 
  916                    cbs_h264_read_end_of_stream)(
ctx, &gbc, unit->
content);
 
  943     switch (unit->
type) {
 
  948             err = cbs_h265_read_vps(
ctx, &gbc, 
vps);
 
  952             err = cbs_h265_replace_vps(
ctx, unit);
 
  961             err = cbs_h265_read_sps(
ctx, &gbc, 
sps);
 
  965             err = cbs_h265_replace_sps(
ctx, unit);
 
  975             err = cbs_h265_read_pps(
ctx, &gbc, 
pps);
 
  979             err = cbs_h265_replace_pps(
ctx, unit);
 
 1005             err = cbs_h265_read_slice_segment_header(
ctx, &gbc, &slice->
header);
 
 1026             err = cbs_h265_read_aud(
ctx, &gbc, unit->
content);
 
 1035             err = cbs_h265_read_sei(
ctx, &gbc, unit->
content,
 
 1064     switch (unit->
type) {
 
 1067             err = cbs_h266_read_dci(
ctx, &gbc, unit->
content);
 
 1075             err = cbs_h266_read_opi(
ctx, &gbc, unit->
content);
 
 1085             err = cbs_h266_read_vps(
ctx, &gbc, 
vps);
 
 1089             err = cbs_h266_replace_vps(
ctx, unit);
 
 1098             err = cbs_h266_read_sps(
ctx, &gbc, 
sps);
 
 1102             err = cbs_h266_replace_sps(
ctx, unit);
 
 1112             err = cbs_h266_read_pps(
ctx, &gbc, 
pps);
 
 1116             err = cbs_h266_replace_pps(
ctx, unit);
 
 1125             err = cbs_h266_read_aps(
ctx, &gbc, unit->
content,
 
 1135             err = cbs_h266_read_ph(
ctx, &gbc, 
ph);
 
 1138             err = cbs_h266_replace_ph(
ctx, unit, &
ph->ph_picture_header);
 
 1156             err = cbs_h266_read_slice_header(
ctx, &gbc, &slice->
header);
 
 1184             err = cbs_h266_read_aud(
ctx, &gbc, unit->
content);
 
 1193             err = cbs_h266_read_sei(
ctx, &gbc, unit->
content,
 
 1209                                       size_t data_size, 
int data_bit_start)
 
 1211     size_t rest  = data_size - (data_bit_start + 7) / 8;
 
 1212     const uint8_t *
pos = 
data + data_bit_start / 8;
 
 1215                data_size > data_bit_start / 8);
 
 1221         goto rbsp_stop_one_bit;
 
 1226     if (data_bit_start % 8)
 
 1227         put_bits(pbc, 8 - data_bit_start % 8,
 
 1244         for (; rest > 4; rest -= 4, 
pos += 4)
 
 1247         for (; rest > 1; rest--, 
pos++)
 
 1256         i = rest ? (8 - 
i) : (8 - 
i - data_bit_start % 8);
 
 1271     switch (unit->
type) {
 
 1276             err = cbs_h264_write_sps(
ctx, pbc, 
sps);
 
 1280             err = cbs_h264_replace_sps(
ctx, unit);
 
 1290             err = cbs_h264_write_sps_extension(
ctx, pbc, sps_ext);
 
 1300             err = cbs_h264_write_pps(
ctx, pbc, 
pps);
 
 1304             err = cbs_h264_replace_pps(
ctx, unit);
 
 1316             err = cbs_h264_write_slice_header(
ctx, pbc, &slice->
header);
 
 1335             err = cbs_h264_write_aud(
ctx, pbc, unit->
content);
 
 1343             err = cbs_h264_write_sei(
ctx, pbc, unit->
content);
 
 1351             err = cbs_h264_write_filler(
ctx, pbc, unit->
content);
 
 1359             err = cbs_h264_write_end_of_sequence(
ctx, pbc, unit->
content);
 
 1367             err = cbs_h264_write_end_of_stream(
ctx, pbc, unit->
content);
 
 1375                "NAL unit type %"PRIu32
".\n", unit->
type);
 
 1388     switch (unit->
type) {
 
 1393             err = cbs_h265_write_vps(
ctx, pbc, 
vps);
 
 1397             err = cbs_h265_replace_vps(
ctx, unit);
 
 1407             err = cbs_h265_write_sps(
ctx, pbc, 
sps);
 
 1411             err = cbs_h265_replace_sps(
ctx, unit);
 
 1421             err = cbs_h265_write_pps(
ctx, pbc, 
pps);
 
 1425             err = cbs_h265_replace_pps(
ctx, unit);
 
 1450             err = cbs_h265_write_slice_segment_header(
ctx, pbc, &slice->
header);
 
 1468             err = cbs_h265_write_aud(
ctx, pbc, unit->
content);
 
 1477             err = cbs_h265_write_sei(
ctx, pbc, unit->
content,
 
 1487                "NAL unit type %"PRIu32
".\n", unit->
type);
 
 1500     int slice_type_i, slice_type_b, slice_type_si;
 
 1520                 "h264 nal unit header is null, missing decompose?\n");
 
 1530                 "h264 slice header is null, missing decompose?\n");
 
 1555     switch (unit->
type) {
 
 1590                 "h265 slice header is null, missing decompose?\n");
 
 1600         switch (unit->
type) {
 
 1625     switch (unit->
type) {
 
 1630             err = cbs_h266_write_dci(
ctx, pbc, 
dci);
 
 1639             err = cbs_h266_write_opi(
ctx, pbc, 
opi);
 
 1648             err = cbs_h266_write_vps(
ctx, pbc, 
vps);
 
 1652             err = cbs_h266_replace_vps(
ctx, unit);
 
 1661             err = cbs_h266_write_sps(
ctx, pbc, 
sps);
 
 1665             err = cbs_h266_replace_sps(
ctx, unit);
 
 1675             err = cbs_h266_write_pps(
ctx, pbc, 
pps);
 
 1679             err = cbs_h266_replace_pps(
ctx, unit);
 
 1688             err = cbs_h266_write_aps(
ctx, pbc, unit->
content,
 
 1697             err = cbs_h266_write_ph(
ctx, pbc, 
ph);
 
 1701             err = cbs_h266_replace_ph(
ctx, unit, &
ph->ph_picture_header);
 
 1718             err = cbs_h266_write_slice_header(
ctx, pbc, &slice->
header);
 
 1742             err = cbs_h266_write_aud(
ctx, pbc, unit->
content);
 
 1751             err = cbs_h266_write_sei(
ctx, pbc, unit->
content,
 
 1761                "NAL unit type %"PRIu32
".\n", unit->
type);
 
 1773     if (nal_unit_index == 0) {
 
 1790     size_t max_size, dp, 
sp;
 
 1791     int err, 
i, zero_run;
 
 1813             if (i < frag->nb_units - 1)
 
 1815                        "unaligned padding on non-final NAL unit.\n");
 
 1837                 if ((unit->
data[
sp] & ~3) == 0) {
 
 1841                 zero_run = unit->
data[
sp] == 0;
 
 2088 #define SEI_MESSAGE_RW(codec, name) \ 
 2089     .read  = cbs_ ## codec ## _read_  ## name ## _internal, \ 
 2090     .write = cbs_ ## codec ## _write_ ## name ## _internal 
 2263     switch (
ctx->codec->codec_id) {
 
  
@ SEI_TYPE_ALPHA_CHANNEL_INFO
H265RawVPS * vps[HEVC_MAX_VPS_COUNT]
RefStruct references.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
void * content_ref
If content is reference counted, a RefStruct reference backing content.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
#define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func)
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
CodedBitstreamH2645Context common
#define cbs_h266_replace_ps(h26n, ps_name, ps_var, id_element)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
void * content
Pointer to the decomposed form of this unit.
H265RawSliceHeader header
static int get_bits_count(const GetBitContext *s)
H264RawPPS * pps[H264_MAX_PPS_COUNT]
RefStruct references.
static int FUNC() ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static const CodedBitstreamUnitTypeDescriptor cbs_h266_unit_types[]
H265RawSPS * sps[HEVC_MAX_SPS_COUNT]
RefStruct references.
Context structure for coded bitstream operations.
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
#define AV_LOG_VERBOSE
Detailed information.
CodedBitstreamUnitType type
Codec-specific type of this unit.
static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
RefStruct is an API for creating reference-counted objects with minimal overhead.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
CodedBitstreamH2645Context common
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int cbs_h2645_unit_requires_zero_byte(enum AVCodecID codec_id, CodedBitstreamUnitType type, int nal_unit_index)
Coded bitstream unit structure.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
H266RawPPS * pps[VVC_MAX_PPS_COUNT]
RefStruct references.
static void cbs_h265_flush(CodedBitstreamContext *ctx)
H266RawVPS * vps[VVC_MAX_VPS_COUNT]
RefStruct references.
static const SEIMessageTypeDescriptor cbs_sei_h265_types[]
const H264RawSPS * active_sps
static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const H2645Packet *packet)
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
static void cbs_h264_flush(CodedBitstreamContext *ctx)
@ CBS_CONTENT_TYPE_INTERNAL_REFS
static int put_bits_left(PutBitContext *s)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
@ SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT
@ H264_NAL_AUXILIARY_SLICE
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
@ SEI_TYPE_FILLER_PAYLOAD
static const SEIMessageTypeDescriptor cbs_sei_common_types[]
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int FUNC() extension_data(CodedBitstreamContext *ctx, RWContext *rw, H265RawExtensionData *current)
#define FF_ARRAY_ELEMS(a)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int cbs_read_ue_golomb(CodedBitstreamContext *ctx, GetBitContext *gbc, const char *name, const int *subscripts, uint32_t *write_to, uint32_t range_min, uint32_t range_max)
Coded bitstream fragment structure, combining one or more units.
size_t data_size
The number of bytes in the bitstream.
static const SEIMessageTypeDescriptor cbs_sei_h266_types[]
static void cbs_h265_free_sei(FFRefStructOpaque unused, void *content)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define SEI_MESSAGE_TYPE_END
@ SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, CodedBitstreamUnitType type, uint8_t *data, size_t data_size, AVBufferRef *data_buf)
Add a new unit to a fragment with the given data bitstream.
#define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element)
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
#define MAX_UINT_BITS(length)
@ AVDISCARD_BIDIR
discard all bidirectional frames
#define CBS_TRACE_WRITE_END()
static int cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t payload_size, int cur_pos)
@ AVDISCARD_ALL
discard all
static int cbs_h266_read_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
H266RawExtensionData extension_data
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
static void cbs_h266_close(CodedBitstreamContext *ctx)
size_t data_size
The number of bytes in the bitstream (including any padding bits in the final byte).
void(* flush)(AVBSFContext *ctx)
static int FUNC() opi(CodedBitstreamContext *ctx, RWContext *rw, H266RawOPI *current)
CodedBitstreamH2645Context common
#define CBS_UNIT_RANGE_INTERNAL_REF(range_start, range_end, structure, ref_field)
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static const CodedBitstreamUnitTypeDescriptor cbs_h264_unit_types[]
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
AVCodecID
Identify the syntax and semantics of the bitstream.
static av_always_inline int bytestream2_tell(GetByteContext *g)
@ AVDISCARD_NONKEY
discard all frames except keyframes
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
@ AVDISCARD_DEFAULT
discard useless packets like 0 size packets in avi
const FFCodec * codec_list[]
H266RawPictureHeader * ph
uint8_t * data
Pointer to the bitstream form of this fragment.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
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
static const uint8_t header[24]
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int is_nalff, int nal_length_size, enum AVCodecID codec_id, int small_padding, int use_ref)
Split an input packet into NAL units.
@ SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
#define CBS_UNIT_TYPE_POD(type_, structure)
@ SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS
static int cbs_h264_discarded_nal_unit(CodedBitstreamContext *ctx, const CodedBitstreamUnit *unit, enum AVDiscard skip)
static void cbs_h265_close(CodedBitstreamContext *ctx)
const H264RawPPS * active_pps
const SEIMessageTypeDescriptor * ff_cbs_sei_find_type(CodedBitstreamContext *ctx, int payload_type)
Find the type descriptor for the given payload type.
H264RawSliceHeader header
uint8_t last_slice_nal_unit_type
@ AVDISCARD_NONINTRA
discard all non intra frames
AVBufferRef * data_ref
A reference to the buffer containing data.
#define i(width, name, range_min, range_max)
static int put_bits_count(PutBitContext *s)
#define CBS_UNIT_TYPES_COMPLEX(types, structure, free_func)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
static void cbs_h266_flush(CodedBitstreamContext *ctx)
H266RawSPS * sps[VVC_MAX_SPS_COUNT]
RefStruct references.
enum AVPacketSideDataType packet
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
@ SEI_TYPE_DISPLAY_ORIENTATION
static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, const char *name, const int *subscripts, int32_t value, int32_t range_min, int32_t range_max)
int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Make the content of a unit refcounted.
#define SEI_MESSAGE_RW(codec, name)
const H265RawSPS * active_sps
#define CBS_UNIT_TYPE_END_OF_LIST
static int cbs_read_se_golomb(CodedBitstreamContext *ctx, GetBitContext *gbc, const char *name, const int *subscripts, int32_t *write_to, int32_t range_min, int32_t range_max)
static void cbs_h264_close(CodedBitstreamContext *ctx)
static void cbs_h264_free_sei(FFRefStructOpaque unused, void *content)
H265RawPPS * pps[HEVC_MAX_PPS_COUNT]
RefStruct references.
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
void ff_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
H266RawSliceHeader header
int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Allocate a new internal content buffer matching the type of the unit.
#define AV_INPUT_BUFFER_PADDING_SIZE
const H265RawPPS * active_pps
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
@ SEI_TYPE_BUFFERING_PERIOD
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
@ SEI_TYPE_USER_DATA_UNREGISTERED
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
const H265RawVPS * active_vps
static int ref[MAX_W *MAX_W]
static void cbs_h266_free_sei(FFRefStructOpaque unused, void *content)
static int cbs_write_ue_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, const char *name, const int *subscripts, uint32_t value, uint32_t range_min, uint32_t range_max)
@ SEI_TYPE_RECOVERY_POINT
static int FUNC() dci(CodedBitstreamContext *ctx, RWContext *rw, H266RawDCI *current)
@ SEI_TYPE_DECODED_PICTURE_HASH
static int cbs_h265_discarded_nal_unit(CodedBitstreamContext *ctx, const CodedBitstreamUnit *unit, enum AVDiscard skip)
A reference to a data buffer.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
const CodedBitstreamType ff_cbs_type_h266
static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
#define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field)
static int cbs_h2645_write_slice_data(CodedBitstreamContext *ctx, PutBitContext *pbc, const uint8_t *data, size_t data_size, int data_bit_start)
static const CodedBitstreamUnitTypeDescriptor cbs_h265_unit_types[]
void * ph_ref
RefStruct reference backing ph above.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
const CodedBitstreamType ff_cbs_type_h264
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
@ SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO
AVBufferRef * data_ref
A reference to the buffer containing data.
static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
void ff_cbs_sei_free_message_list(SEIRawMessageList *list)
Free all SEI messages in a message list.
@ AVDISCARD_NONREF
discard all non reference
H264RawSPS * sps[H264_MAX_SPS_COUNT]
RefStruct references.
@ SEI_TYPE_FILM_GRAIN_CHARACTERISTICS
const CodedBitstreamType ff_cbs_type_h265
#define CBS_TRACE_READ_START()
@ SEI_TYPE_ACTIVE_PARAMETER_SETS
void * priv_data
Format private data.
static int cbs_h264_write_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
void ff_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static const SEIMessageTypeDescriptor cbs_sei_h264_types[]
static int cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
int nb_units
Number of units in this fragment.
static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
static int cbs_h266_write_nal_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
#define CBS_TRACE_READ_END()
#define CBS_TRACE_WRITE_START()