FFmpeg
evc.h
Go to the documentation of this file.
1 /*
2  * EVC helper functions for muxers
3  * Copyright (c) 2022 Dawid Kozinski <d.kozinski@samsung.com>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVFORMAT_EVC_H
23 #define AVFORMAT_EVC_H
24 
25 #include <stdint.h>
26 
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/rational.h"
29 #include "libavcodec/evc.h"
30 #include "avio.h"
31 
32 static inline int evc_get_nalu_type(const uint8_t *p, int bits_size)
33 {
34  int unit_type_plus1 = 0;
35 
37  // forbidden_zero_bit
38  if ((p[0] & 0x80) != 0) // Cannot get bitstream information. Malformed bitstream.
39  return -1;
40 
41  // nal_unit_type
42  unit_type_plus1 = (p[0] >> 1) & 0x3F;
43  }
44 
45  return unit_type_plus1 - 1;
46 }
47 
48 static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_size)
49 {
51  return AV_RB32(bits);
52 
53  return 0;
54 }
55 
56 /**
57  * Writes EVC sample metadata to the provided AVIOContext.
58  *
59  * @param pb pointer to the AVIOContext where the evc sample metadata shall be written
60  * @param buf input data buffer
61  * @param size size in bytes of the input data buffer
62  * @param ps_array_completeness @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.3
63  *
64  * @return 0 in case of success, a negative error code in case of failure
65  */
66 int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data,
67  int size, int ps_array_completeness);
68 
69 #endif // AVFORMAT_EVC_H
rational.h
data
const char data[16]
Definition: mxf.c:148
evc_get_nalu_type
static int evc_get_nalu_type(const uint8_t *p, int bits_size)
Definition: evc.h:32
EVC_NALU_HEADER_SIZE
#define EVC_NALU_HEADER_SIZE
Definition: evc.h:27
intreadwrite.h
bits
uint8_t bits
Definition: vp3data.h:128
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
size
int size
Definition: twinvq_data.h:10344
avio.h
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
EVC_NALU_LENGTH_PREFIX_SIZE
#define EVC_NALU_LENGTH_PREFIX_SIZE
Definition: evc.h:26
ff_isom_write_evcc
int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness)
Writes EVC sample metadata to the provided AVIOContext.
Definition: evc.c:299
bits_size
#define bits_size
Definition: bitstream.h:113
evc.h
evc_read_nal_unit_length
static uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_size)
Definition: evc.h:48