44#define UAVS3D_CHECK_START_CODE(data_ptr, PIC_START_CODE) \
45 (AV_RL32(data_ptr) != (PIC_START_CODE << 24) + AVS3_NAL_START_CODE)
48 const unsigned char *data_ptr = bs_data + 4;
49 int count = bs_len - 4;
70 uavs3d_io_frm_t frm_out;
74 if (!frm || !frm->
data[0]) {
75 dec_frame->got_pic = 0;
80 frm->
pts = dec_frame->pts;
93 for (
i = 0;
i < 3;
i++) {
94 frm_out.width [
i] = dec_frame->width[
i];
95 frm_out.height[
i] = dec_frame->height[
i];
97 frm_out.buffer[
i] = frm->
data[
i];
100 uavs3d_img_cpy_cvt(&frm_out, dec_frame, dec_frame->bit_depth);
103#define UAVS3D_CHECK_INVALID_RANGE(v, l, r) ((v)<(l)||(v)>(r))
108 uavs3d_io_frm_t *frm_dec = &
h->dec_frame;
109 struct uavs3d_com_seqh_t *seqh = frm_dec->seqhdr;
114 seqh->frame_rate_code = 3;
126 if (seqh->colour_description) {
131 "Invalid colour description: primaries: %d"
132 "transfer characteristics: %d"
133 "matrix coefficients: %d.\n",
134 seqh->colour_primaries,
135 seqh->transfer_characteristics,
136 seqh->matrix_coefficients);
152 uavs3d_io_frm_t *frm_dec = &
h->dec_frame;
167 frm_dec->nal_type = 0;
168 frm_dec->pkt_pos = 0;
169 frm_dec->pkt_size = header_size;
171 frm_dec->bs_len = header_size;
174 uavs3d_decode(
h->dec_handle, frm_dec);
175 if (frm_dec->nal_type == NAL_SEQ_HEADER) {
179 "Process sequence header failed, %s\n",
av_err2str(ret));
182 "Missing sequence header in extradata\n");
198 if (!
h->dec_handle) {
213 uavs3d_flush(
h->dec_handle,
NULL);
214 uavs3d_delete(
h->dec_handle);
215 h->dec_handle =
NULL;
227 uavs3d_reset(
h->dec_handle);
235 const uint8_t *buf = avpkt->
data;
236 int buf_size = avpkt->
size;
237 const uint8_t *buf_end;
238 const uint8_t *buf_ptr = buf;
251 h->dec_frame.priv = frm;
254 ret = uavs3d_flush(
h->dec_handle, &
h->dec_frame);
255 }
while (ret > 0 && !
h->dec_frame.got_pic);
257 uavs3d_io_frm_t *frm_dec = &
h->dec_frame;
259 buf_end = buf + buf_size;
268 h->dec_frame.priv = frm;
272 bs_len = buf_end - buf_ptr - left_bytes;
274 bs_len = buf_end - buf_ptr;
277 frm_dec->bs = (
unsigned char *)buf_ptr;
278 frm_dec->bs_len = bs_len;
279 frm_dec->pts = avpkt->
pts;
280 frm_dec->dts = avpkt->
dts;
281 uavs3d_decode(
h->dec_handle, frm_dec);
284 if (frm_dec->nal_type == NAL_SEQ_HEADER) {
289 if (frm_dec->got_pic) {
295 *got_frame =
h->dec_frame.got_pic;
301 return buf_ptr - buf;
305 .p.name =
"libuavs3d",
317 .p.wrapper_name =
"libuavs3d",
const FFCodec ff_libuavs3d_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
static const AVRational ff_avs3_frame_rate_tab[16]
#define AVS3_INTRA_PIC_START_CODE
#define AVS3_FIRST_SLICE_START_CODE
#define AVS3_SEQ_START_CODE
#define AVS3_INTER_PIC_START_CODE
static const int ff_avs3_color_primaries_tab[10]
static const int ff_avs3_color_transfer_tab[15]
static enum AVPictureType ff_avs3_image_type[4]
static const int ff_avs3_color_matrix_tab[12]
#define AVS3_SEQ_END_CODE
Convenience header that includes libavutil's core.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
common internal and external API header
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_NONE
Undefined.
static void libuavs3d_flush(AVCodecContext *avctx)
static av_cold int libuavs3d_init(AVCodecContext *avctx)
static av_cold int libuavs3d_end(AVCodecContext *avctx)
static int libuavs3d_on_seq_header(AVCodecContext *avctx)
static int libuavs3d_decode_extradata(AVCodecContext *avctx)
#define UAVS3D_CHECK_INVALID_RANGE(v, l, r)
#define UAVS3D_CHECK_START_CODE(data_ptr, PIC_START_CODE)
static int libuavs3d_decode_frame(AVCodecContext *avctx, AVFrame *frm, int *got_frame, AVPacket *avpkt)
static int uavs3d_find_next_start_code(const unsigned char *bs_data, int bs_len, int *left)
static void uavs3d_output_callback(uavs3d_io_frm_t *dec_frame)
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static const uint8_t header[24]
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
int has_b_frames
Size of the frame reordering buffer in the decoder.
enum AVColorSpace colorspace
YUV colorspace type.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
uavs3d_io_frm_t dec_frame