Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,4 @@ output/
packages/react-native-audio-api/android/src/main/jniLibs/
packages/react-native-audio-api/common/cpp/audioapi/external/**/*.a
packages/react-native-audio-api/common/cpp/audioapi/external/*.xcframework
packages/react-native-audio-api/common/cpp/audioapi/external/ffmpeg_ios/
8 changes: 4 additions & 4 deletions packages/react-native-audio-api/RNAudioAPI.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ Pod::Spec.new do |s|
lib_dir = "$(PROJECT_DIR)/#{rn_audio_dir_relative}/#{external_dir_relative}/$(PLATFORM_NAME)"

s.ios.vendored_frameworks = [
'common/cpp/audioapi/external/libavcodec.xcframework',
'common/cpp/audioapi/external/libavformat.xcframework',
'common/cpp/audioapi/external/libavutil.xcframework',
'common/cpp/audioapi/external/libswresample.xcframework'
'common/cpp/audioapi/external/ffmpeg_ios/libavcodec.xcframework',
'common/cpp/audioapi/external/ffmpeg_ios/libavformat.xcframework',
'common/cpp/audioapi/external/ffmpeg_ios/libavutil.xcframework',
'common/cpp/audioapi/external/ffmpeg_ios/libswresample.xcframework'
]
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ typedef struct RcOverride{
#define AV_CODEC_FLAG_QPEL (1 << 4)
/**
* Request the encoder to output reconstructed frames, i.e.\ frames that would
* be produced by decoding the encoded bistream. These frames may be retrieved
* be produced by decoding the encoded bitstream. These frames may be retrieved
* by calling avcodec_receive_frame() immediately after a successful call to
* avcodec_receive_packet().
*
Expand Down Expand Up @@ -2900,7 +2900,7 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
*
* @note for encoders, this function will only do something if the encoder
* declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder
* will drain any remaining packets, and can then be re-used for a different
* will drain any remaining packets, and can then be reused for a different
* stream (as opposed to sending a null frame which will leave the encoder
* in a permanent EOF state after draining). This can be desirable if the
* cost of tearing down and replacing the encoder instance is high.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ enum AVCodecID {
AV_CODEC_ID_RV60,
AV_CODEC_ID_JPEGXL_ANIM,
AV_CODEC_ID_APV,
AV_CODEC_ID_PRORES_RAW,

/* various PCM "codecs" */
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
Expand Down Expand Up @@ -602,6 +603,7 @@ enum AVCodecID {
AV_CODEC_ID_BIN_DATA,
AV_CODEC_ID_SMPTE_2038,
AV_CODEC_ID_LCEVC,
AV_CODEC_ID_SMPTE_436M_ANC,


AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ typedef struct AVCodecParameters {
* durations. Should be set to { 0, 1 } when some frames have differing
* durations or if the value is not known.
*
* @note This field correponds to values that are stored in codec-level
* @note This field corresponds to values that are stored in codec-level
* headers and is typically overridden by container/transport-layer
* timestamps, when available. It should thus be used only as a last resort,
* when no higher-level timing information is available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
#define AV_PROFILE_PRORES_4444 4
#define AV_PROFILE_PRORES_XQ 5

#define AV_PROFILE_PRORES_RAW 0
#define AV_PROFILE_PRORES_RAW_HQ 1

#define AV_PROFILE_ARIB_PROFILE_A 0
#define AV_PROFILE_ARIB_PROFILE_C 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ enum AVPacketSideDataType {
AV_PKT_DATA_CPB_PROPERTIES,

/**
* Recommmends skipping the specified number of samples
* Recommends skipping the specified number of samples
* @code
* u32le number of samples to skip from start of this packet
* u32le number of samples to skip from end of this packet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
/*
* MXF SMPTE-436M VBI/ANC parsing functions
* Copyright (c) 2025 Jacob Lifshay
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef AVCODEC_SMPTE_436M_H
#define AVCODEC_SMPTE_436M_H

#include <stdint.h>

/**
* Iterator over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data
*/
typedef struct AVSmpte436mAncIterator {
uint16_t anc_packets_left;
int size_left;
const uint8_t *data_left;
} AVSmpte436mAncIterator;

/**
* Wrapping Type from Table 7 (page 13) of:
* https://pub.smpte.org/latest/st436/s436m-2006.pdf
*/
typedef enum AVSmpte436mWrappingType
{
AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME = 1,
AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_1 = 2,
AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_2 = 3,
AV_SMPTE_436M_WRAPPING_TYPE_VANC_PROGRESSIVE_FRAME = 4,
AV_SMPTE_436M_WRAPPING_TYPE_HANC_FRAME = 0x11,
AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_1 = 0x12,
AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_2 = 0x13,
AV_SMPTE_436M_WRAPPING_TYPE_HANC_PROGRESSIVE_FRAME = 0x14,
/** not a real wrapping type, just here to guarantee the enum is big enough */
AV_SMPTE_436M_WRAPPING_TYPE_MAX = 0xFF,
} AVSmpte436mWrappingType;

/**
* Payload Sample Coding from Table 4 (page 10) and Table 7 (page 13) of:
* https://pub.smpte.org/latest/st436/s436m-2006.pdf
*/
typedef enum AVSmpte436mPayloadSampleCoding
{
/** only used for VBI */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_LUMA = 1,
/** only used for VBI */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_COLOR_DIFF = 2,
/** only used for VBI */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_LUMA_AND_COLOR_DIFF = 3,
/** used for VBI and ANC */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA = 4,
/** used for VBI and ANC */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_COLOR_DIFF = 5,
/** used for VBI and ANC */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_AND_COLOR_DIFF = 6,
/** used for VBI and ANC */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_LUMA = 7,
/** used for VBI and ANC */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_COLOR_DIFF = 8,
/** used for VBI and ANC */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_LUMA_AND_COLOR_DIFF = 9,
/** only used for ANC */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_WITH_PARITY_ERROR = 10,
/** only used for ANC */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_COLOR_DIFF_WITH_PARITY_ERROR = 11,
/** only used for ANC */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_AND_COLOR_DIFF_WITH_PARITY_ERROR = 12,
/** not a real sample coding, just here to guarantee the enum is big enough */
AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_MAX = 0xFF,
} AVSmpte436mPayloadSampleCoding;

/** the payload capacity of AVSmpte291mAnc8bit (and of AVSmpte291mAnc10bit when that gets added) */
#define AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY 0xFF

/**
* An ANC packet with an 8-bit payload.
* This can be decoded from AVSmpte436mCodedAnc::payload.
*
* Note: Some ANC packets need a 10-bit payload, if stored in this struct,
* the most-significant 2 bits of each sample are discarded.
*/
typedef struct AVSmpte291mAnc8bit {
uint8_t did;
uint8_t sdid_or_dbn;
uint8_t data_count;
uint8_t payload[AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY];
uint8_t checksum;
} AVSmpte291mAnc8bit;

/** max number of samples that can be stored in the payload of AVSmpte436mCodedAnc */
#define AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY \
(AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY + 4) /* 4 for did, sdid_or_dbn, data_count, and checksum */
/** max number of bytes that can be stored in the payload of AVSmpte436mCodedAnc */
#define AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY (((AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY + 2) / 3) * 4)

/**
* An encoded ANC packet within a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
* The repeated section of Table 7 (page 13) of:
* https://pub.smpte.org/latest/st436/s436m-2006.pdf
*/
typedef struct AVSmpte436mCodedAnc {
uint16_t line_number;
AVSmpte436mWrappingType wrapping_type;
AVSmpte436mPayloadSampleCoding payload_sample_coding;
uint16_t payload_sample_count;
uint32_t payload_array_length;
/** the payload, has size payload_array_length.
* can be decoded into AVSmpte291mAnc8bit
*/
uint8_t payload[AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY];
} AVSmpte436mCodedAnc;

/**
* Validate a AVSmpte436mCodedAnc structure. Doesn't check if the payload is valid.
* @param[in] anc ANC packet to validate
* @return 0 on success, AVERROR codes otherwise.
*/
int av_smpte_436m_coded_anc_validate(const AVSmpte436mCodedAnc *anc);

/**
* Encode ANC packets into a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
* @param[in] anc_packet_count number of ANC packets to encode
* @param[in] anc_packets the ANC packets to encode
* @param[in] size the size of out. ignored if out is NULL.
* @param[out] out Output bytes. Doesn't write anything if out is NULL.
* @return the number of bytes written on success, AVERROR codes otherwise.
* If out is NULL, returns the number of bytes it would have written.
*/
int av_smpte_436m_anc_encode(uint8_t *out, int size, int anc_packet_count, const AVSmpte436mCodedAnc *anc_packets);

struct AVPacket;

/**
* Append more ANC packets to a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
* @param[in] anc_packet_count number of ANC packets to encode
* @param[in] anc_packets the ANC packets to encode
* @param pkt the AVPacket to append to.
* it must either be size 0 or contain valid SMPTE_436M_ANC data.
* @return 0 on success, AVERROR codes otherwise.
*/
int av_smpte_436m_anc_append(struct AVPacket *pkt, int anc_packet_count, const AVSmpte436mCodedAnc *anc_packets);

/**
* Set up iteration over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
* @param[in] buf Pointer to the data from a AV_CODEC_ID_SMPTE_436M_ANC AVPacket.
* @param[in] buf_size Size of the data from a AV_CODEC_ID_SMPTE_436M_ANC AVPacket.
* @param[out] iter Pointer to the iterator.
* @return 0 on success, AVERROR codes otherwise.
*/
int av_smpte_436m_anc_iter_init(AVSmpte436mAncIterator *iter, const uint8_t *buf, int buf_size);

/**
* Get the next ANC packet from the iterator, advancing the iterator.
* @param[in,out] iter Pointer to the iterator.
* @param[out] anc The returned ANC packet.
* @return 0 on success, AVERROR_EOF when the iterator has reached the end, AVERROR codes otherwise.
*/
int av_smpte_436m_anc_iter_next(AVSmpte436mAncIterator *iter, AVSmpte436mCodedAnc *anc);

/**
* Get the minimum number of bytes needed to store a AVSmpte436mCodedAnc payload.
* @param sample_coding the payload sample coding
* @param sample_count the number of samples stored in the payload
* @return returns the minimum number of bytes needed, on error returns < 0.
* always <= SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY
*/
int av_smpte_436m_coded_anc_payload_size(AVSmpte436mPayloadSampleCoding sample_coding, uint16_t sample_count);

/**
* Decode a AVSmpte436mCodedAnc payload into AVSmpte291mAnc8bit
* @param[in] sample_coding the payload sample coding
* @param[in] sample_count the number of samples stored in the payload
* @param[in] payload the bytes storing the payload,
* the needed size can be obtained from
avpriv_smpte_436m_coded_anc_payload_size
* @param[in] log_ctx context pointer for av_log
* @param[out] out The decoded ANC packet.
* @return returns 0 on success, otherwise < 0.
*/
int av_smpte_291m_anc_8bit_decode(AVSmpte291mAnc8bit *out,
AVSmpte436mPayloadSampleCoding sample_coding,
uint16_t sample_count,
const uint8_t *payload,
void *log_ctx);

/**
* Fill in the correct checksum for a AVSmpte291mAnc8bit
* @param[in,out] anc The ANC packet.
*/
void av_smpte_291m_anc_8bit_fill_checksum(AVSmpte291mAnc8bit *anc);

/**
* Compute the sample count needed to encode a AVSmpte291mAnc8bit into a AVSmpte436mCodedAnc payload
* @param[in] anc The ANC packet.
* @param[in] sample_coding The sample coding.
* @param[in] log_ctx context pointer for av_log
* @return returns the sample count on success, otherwise < 0.
*/
int av_smpte_291m_anc_8bit_get_sample_count(const AVSmpte291mAnc8bit *anc,
AVSmpte436mPayloadSampleCoding sample_coding,
void *log_ctx);

/**
* Encode a AVSmpte291mAnc8bit into a AVSmpte436mCodedAnc
* @param[in] line_number the line number the ANC packet is on
* @param[in] wrapping_type the wrapping type
* @param[in] sample_coding the payload sample coding
* @param[in] payload the ANC packet to encode.
* @param[in] log_ctx context pointer for av_log
* @param[out] out The encoded ANC packet.
* @return returns 0 on success, otherwise < 0.
*/
int av_smpte_291m_anc_8bit_encode(AVSmpte436mCodedAnc *out,
uint16_t line_number,
AVSmpte436mWrappingType wrapping_type,
AVSmpte436mPayloadSampleCoding sample_coding,
const AVSmpte291mAnc8bit *payload,
void *log_ctx);

/** AVSmpte291mAnc8bit::did when carrying CTA-708 data (for AV_CODEC_ID_EIA_608) */
#define AV_SMPTE_291M_ANC_DID_CTA_708 0x61

/** AVSmpte291mAnc8bit::sdid_or_dbn when carrying CTA-708 data (for AV_CODEC_ID_EIA_608) */
#define AV_SMPTE_291M_ANC_SDID_CTA_708 0x1

/**
* Try to decode an ANC packet into EIA-608/CTA-708 data (AV_CODEC_ID_EIA_608). This
* @param[in] anc The ANC packet.
* @param[in] log_ctx Context pointer for av_log
* @param[out] cc_data the buffer to store the extracted EIA-608/CTA-708 data,
* you can pass NULL to not store the data.
* the required size is 3 * cc_count bytes.
* SMPTE_291M_ANC_PAYLOAD_CAPACITY is always enough size.
* @return returns cc_count (>= 0) on success, AVERROR(EAGAIN) if it wasn't a CTA-708 ANC packet, < 0 on error.
*/
int av_smpte_291m_anc_8bit_extract_cta_708(const AVSmpte291mAnc8bit *anc, uint8_t *cc_data, void *log_ctx);

#endif /* AVCODEC_SMPTE_436M_H */
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "version_major.h"

#define LIBAVCODEC_VERSION_MINOR 8
#define LIBAVCODEC_VERSION_MINOR 11
#define LIBAVCODEC_VERSION_MICRO 100

#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ typedef struct AVStream {
* the sixth @ref AVStreamGroup.streams "stream" in the group is "512,512",
* etc.
*
* The following is an example of a canvas with overlaping tiles:
* The following is an example of a canvas with overlapping tiles:
*
* +-----------+
* | %%%%% |
Expand Down Expand Up @@ -1420,7 +1420,7 @@ typedef struct AVFormatContext {
#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input.
#define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
#define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled
#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the filling code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled
#define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible
#define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
#define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted
Expand Down Expand Up @@ -1670,7 +1670,7 @@ typedef struct AVFormatContext {
int use_wallclock_as_timestamps;

/**
* Skip duration calcuation in estimate_timings_from_pts.
* Skip duration calculation in estimate_timings_from_pts.
* - encoding: unused
* - decoding: set by user
*
Expand Down Expand Up @@ -1773,7 +1773,7 @@ typedef struct AVFormatContext {

/**
* IO repositioned flag.
* This is set by avformat when the underlaying IO context read pointer
* This is set by avformat when the underlying IO context read pointer
* is repositioned, for example when doing byte based seeking.
* Demuxers can use the flag to detect such changes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

#include "version_major.h"

#define LIBAVFORMAT_VERSION_MINOR 1
#define LIBAVFORMAT_VERSION_MICRO 103
#define LIBAVFORMAT_VERSION_MINOR 3
#define LIBAVFORMAT_VERSION_MICRO 100

#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
Expand Down
Loading