39 #include <schroedinger/schro.h>
40 #include <schroedinger/schrodebug.h>
41 #include <schroedinger/schrovideoformat.h>
77 const uint8_t *buf,
int buf_size)
85 SchroBuffer *enc_buf =
NULL;
86 int next_pu_offset = 0;
87 unsigned char *in_buf;
90 parse_ctx->
buf[0] !=
'B' ||
91 parse_ctx->
buf[1] !=
'B' ||
92 parse_ctx->
buf[2] !=
'C' ||
93 parse_ctx->
buf[3] !=
'D')
96 next_pu_offset = (parse_ctx->
buf[5] << 24) +
97 (parse_ctx->
buf[6] << 16) +
98 (parse_ctx->
buf[7] << 8) +
101 if (next_pu_offset == 0 &&
102 SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->
buf[4]))
105 if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)
109 memcpy(in_buf, parse_ctx->
buf, next_pu_offset);
110 enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
112 enc_buf->priv = in_buf;
114 parse_ctx->
buf += next_pu_offset;
115 parse_ctx->
buf_size -= next_pu_offset;
129 for (idx = 0; idx < num_formats; ++idx)
142 schro_debug_set_level(avccontext->
debug);
143 p_schro_params->
decoder = schro_decoder_new();
144 schro_decoder_set_skip_ratio(p_schro_params->
decoder, 1);
162 schro_frame_unref(frame);
170 p_schro_params->
format = schro_decoder_get_video_format(decoder);
174 0, avccontext) < 0) {
176 p_schro_params->
format->width, p_schro_params->
format->height);
187 "This codec currently only supports planar YUV 4:2:0, 4:2:2 "
188 "and 4:4:4 formats.\n");
203 void *
data,
int *data_size,
206 const uint8_t *buf = avpkt->
data;
207 int buf_size = avpkt->
size;
212 SchroBuffer *enc_buf;
224 state = schro_decoder_push_end_of_stream(decoder);
233 if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
234 SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
236 state = schro_decoder_push(decoder, enc_buf);
237 if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
245 state = schro_decoder_wait(decoder);
247 case SCHRO_DECODER_FIRST_ACCESS_UNIT:
251 case SCHRO_DECODER_NEED_BITS:
256 case SCHRO_DECODER_NEED_FRAME:
260 schro_decoder_add_output_picture(decoder, frame);
263 case SCHRO_DECODER_OK:
265 frame = schro_decoder_pull(decoder);
271 case SCHRO_DECODER_EOS:
274 schro_decoder_reset(decoder);
278 case SCHRO_DECODER_ERROR:
290 frame->components[0].data,
291 frame->components[0].length);
294 frame->components[1].data,
295 frame->components[1].length);
298 frame->components[2].data,
299 frame->components[2].length);
319 schro_decoder_free(p_schro_params->
decoder);
342 schro_decoder_reset(p_schro_params->
decoder);
348 .
name =
"libschroedinger",
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext)
SchroChromaFormat schro_pix_fmt
SchroVideoFormat * format
Schroedinger video format.
static void SchroParseContextInit(SchroParseUnitContext *parse_ctx, const uint8_t *buf, int buf_size)
static int libschroedinger_decode_frame(AVCodecContext *avccontext, void *data, int *data_size, AVPacket *avpkt)
four components are given, that's all.
data structures common to libschroedinger decoder and encoder
static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf, void *priv)
SchroFrameFormat frame_format
Schroedinger frame format.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
SchroFrame * ff_create_schro_frame(AVCodecContext *avccontext, SchroFrameFormat schro_frame_fmt)
Create a Schro frame based on the dimensions and frame format passed.
uint8_t * data[AV_NUM_DATA_POINTERS]
static void libschroedinger_flush(AVCodecContext *avccontext)
SchroDecoder * decoder
decoder handle
static int init(AVCodecParserContext *s)
struct SchroDecoderParams SchroDecoderParams
libschroedinger decoder private data
static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
int has_b_frames
Size of the frame reordering buffer in the decoder.
static enum PixelFormat get_chroma_format(SchroChromaFormat schro_pix_fmt)
Returns Libav chroma format.
void * ff_dirac_schro_queue_pop(DiracSchroQueue *queue)
Return the first element in the queue.
A simple queue implementation used in libdirac and libschroedinger.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVCodec ff_libschroedinger_decoder
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
int ff_get_schro_frame_format(SchroChromaFormat schro_pix_fmt, SchroFrameFormat *schro_frame_fmt)
Sets the Schroedinger frame format corresponding to the Schro chroma format passed.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
static const chunk_decoder decoder[8]
int width
picture width / height.
void avpicture_free(AVPicture *picture)
Free a picture previously allocated by avpicture_alloc().
libschroedinger decoder private data
static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext)
int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data)
Add an element to the end of the queue.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
struct AVPicture AVPicture
four components are given, that's all.
int eos_signalled
end of sequence signalled
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int avpicture_fill(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt, int width, int height)
Fill in the AVPicture fields.
int eos_pulled
end of sequence pulled
DiracSchroQueue dec_frame_queue
queue storing decoded frames
int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height)
Allocate memory for a picture.
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
data structures common to libdirac and libschroedinger
struct SchroParseUnitContext SchroParseUnitContext
static SchroBuffer * FindNextSchroParseUnit(SchroParseUnitContext *parse_ctx)
static void libschroedinger_decode_frame_free(void *frame)
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
void ff_dirac_schro_queue_init(DiracSchroQueue *queue)
Initialise the queue.
static const struct @28 schro_pixel_format_map[]
void ff_dirac_schro_queue_free(DiracSchroQueue *queue, void(*free_func)(void *))
Free the queue resources.
AVPicture dec_pic
decoded picture