43 #define UAVS3D_CHECK_START_CODE(data_ptr, PIC_START_CODE) \
44 (AV_RL32(data_ptr) != (PIC_START_CODE << 24) + AVS3_NAL_START_CODE)
47 const unsigned char *data_ptr = bs_data + 4;
48 int count = bs_len - 4;
69 uavs3d_io_frm_t frm_out;
73 if (!frm || !frm->
data[0]) {
74 dec_frame->got_pic = 0;
79 frm->
pts = dec_frame->pts;
81 frm->
pkt_pos = dec_frame->pkt_pos;
86 if (dec_frame->type < 0 || dec_frame->type >= 4) {
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);
113 if (!
h->dec_handle) {
125 uavs3d_flush(
h->dec_handle,
NULL);
126 uavs3d_delete(
h->dec_handle);
127 h->dec_handle =
NULL;
139 uavs3d_reset(
h->dec_handle);
143 #define UAVS3D_CHECK_INVALID_RANGE(v, l, r) ((v)<(l)||(v)>(r))
148 int buf_size = avpkt->
size;
164 h->dec_frame.priv =
data;
167 ret = uavs3d_flush(
h->dec_handle, &
h->dec_frame);
168 }
while (ret > 0 && !
h->dec_frame.got_pic);
170 uavs3d_io_frm_t *frm_dec = &
h->dec_frame;
173 buf_end = buf + buf_size;
174 frm_dec->pkt_pos = avpkt->
pos;
175 frm_dec->pkt_size = avpkt->
size;
184 h->dec_frame.priv =
data;
188 bs_len = buf_end - buf_ptr - left_bytes;
190 bs_len = buf_end - buf_ptr;
193 frm_dec->bs = (
unsigned char *)buf_ptr;
194 frm_dec->bs_len = bs_len;
195 frm_dec->pts = avpkt->
pts;
196 frm_dec->dts = avpkt->
dts;
197 uavs3d_decode(
h->dec_handle, frm_dec);
200 if (frm_dec->nal_type == NAL_SEQ_HEADER) {
201 struct uavs3d_com_seqh_t *seqh = frm_dec->seqhdr;
204 seqh->frame_rate_code = 3;
214 if (seqh->colour_description) {
219 "Invalid colour description: primaries: %d"
220 "transfer characteristics: %d"
221 "matrix coefficients: %d.\n",
222 seqh->colour_primaries,
223 seqh->transfer_characteristics,
224 seqh->matrix_coefficients);
232 if (frm_dec->got_pic) {
238 *got_frame =
h->dec_frame.got_pic;
244 return buf_ptr - buf;
262 .wrapper_name =
"libuavs3d",
static void flush(AVCodecContext *avctx)
simple assert() macros that are a bit more flexible than ISO C assert().
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
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.
common internal and external API header
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#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.
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.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
static void libuavs3d_flush(AVCodecContext *avctx)
static av_cold int libuavs3d_init(AVCodecContext *avctx)
static av_cold int libuavs3d_end(AVCodecContext *avctx)
AVCodec ff_libuavs3d_decoder
#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, void *data, 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)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
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.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
int coded_picture_number
picture number in bitstream order
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int display_picture_number
picture number in display order
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int key_frame
1 -> keyframe, 0-> not
int64_t pkt_pos
reordered pos from the last AVPacket that has been input into the decoder
int pkt_size
size of the corresponding packet containing the compressed frame.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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.
int64_t pos
byte position in stream, -1 if unknown
uavs3d_io_frm_t dec_frame