44 #include <schroedinger/schro.h>
45 #include <schroedinger/schrodebug.h>
46 #include <schroedinger/schrovideoformat.h>
91 const uint8_t *buf,
int buf_size)
99 SchroBuffer *enc_buf =
NULL;
100 int next_pu_offset = 0;
101 unsigned char *in_buf;
104 parse_ctx->
buf[0] !=
'B' ||
105 parse_ctx->
buf[1] !=
'B' ||
106 parse_ctx->
buf[2] !=
'C' ||
107 parse_ctx->
buf[3] !=
'D')
110 next_pu_offset = (parse_ctx->
buf[5] << 24) +
111 (parse_ctx->
buf[6] << 16) +
112 (parse_ctx->
buf[7] << 8) +
115 if (next_pu_offset == 0 &&
116 SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->
buf[4]))
119 if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)
128 memcpy(in_buf, parse_ctx->
buf, next_pu_offset);
129 enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
131 enc_buf->priv = in_buf;
133 parse_ctx->
buf += next_pu_offset;
134 parse_ctx->
buf_size -= next_pu_offset;
148 for (idx = 0; idx < num_formats; ++idx)
161 schro_debug_set_level(avccontext->
debug);
162 p_schro_params->
decoder = schro_decoder_new();
163 schro_decoder_set_skip_ratio(p_schro_params->
decoder, 1);
175 schro_frame_unref(frame);
183 p_schro_params->
format = schro_decoder_get_video_format(decoder);
187 p_schro_params->
format->height, 0, avccontext) < 0) {
189 p_schro_params->
format->width, p_schro_params->
format->height);
200 "This codec currently only supports planar YUV 4:2:0, 4:2:2 "
201 "and 4:4:4 formats.\n");
210 void *
data,
int *got_frame,
214 int buf_size = avpkt->
size;
215 int64_t pts = avpkt->
pts;
220 SchroBuffer *enc_buf;
233 state = schro_decoder_push_end_of_stream(decoder);
243 if (!enc_buf->tag->value) {
247 AV_WN(64, enc_buf->tag->value, pts);
249 if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
250 SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
252 state = schro_decoder_push(decoder, enc_buf);
253 if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
261 state = schro_decoder_wait(decoder);
263 case SCHRO_DECODER_FIRST_ACCESS_UNIT:
267 case SCHRO_DECODER_NEED_BITS:
272 case SCHRO_DECODER_NEED_FRAME:
276 schro_decoder_add_output_picture(decoder, frame);
279 case SCHRO_DECODER_OK:
281 tag = schro_decoder_get_picture_tag(decoder);
282 frame = schro_decoder_pull(decoder);
291 framewithpts->
frame = frame;
297 case SCHRO_DECODER_EOS:
300 schro_decoder_reset(decoder);
304 case SCHRO_DECODER_ERROR:
314 if (framewithpts && framewithpts->
frame) {
323 framewithpts->
frame->components[0].data,
324 framewithpts->
frame->components[0].length);
327 framewithpts->
frame->components[1].data,
328 framewithpts->
frame->components[1].length);
331 framewithpts->
frame->components[2].data,
332 framewithpts->
frame->components[2].length);
361 schro_decoder_free(p_schro_params->
decoder);
385 schro_decoder_reset(p_schro_params->
decoder);
391 .
name =
"libschroedinger",
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
This structure describes decoded (raw) audio or video data.
static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext)
struct LibSchroFrameContext LibSchroFrameContext
SchroFrame and Pts relation.
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
SchroChromaFormat schro_pix_fmt
memory handling functions
SchroVideoFormat * format
Schroedinger video format.
static const struct @34 schro_pixel_format_map[]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static SchroBuffer * find_next_parse_unit(SchroParseUnitContext *parse_ctx)
static enum AVPixelFormat get_chroma_format(SchroChromaFormat schro_pix_fmt)
Returns Libav chroma format.
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.
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 width
width and height of the video frame
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void * ff_schro_queue_pop(FFSchroQueue *queue)
Return the first element in the queue.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void ff_schro_queue_init(FFSchroQueue *queue)
Initialise the queue.
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.
common internal API header
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...
int ff_schro_queue_push_back(FFSchroQueue *queue, void *p_data)
Add an element to the end of the queue.
void ff_schro_queue_free(FFSchroQueue *queue, void(*free_func)(void *))
Free the queue resources.
A simple queue implementation used in libschroedinger.
static const chunk_decoder decoder[8]
int width
picture width / height.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
libschroedinger decoder private data
static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext)
SchroFrame and Pts relation.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
int eos_signalled
end of sequence signalled
FFSchroQueue dec_frame_queue
queue storing decoded frames
int64_t pkt_pts
pts copied from the AVPacket that was decoded to produce this frame
int eos_pulled
end of sequence pulled
static void parse_context_init(SchroParseUnitContext *parse_ctx, const uint8_t *buf, int buf_size)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
static int libschroedinger_decode_frame(AVCodecContext *avccontext, void *data, int *got_frame, AVPacket *avpkt)
struct SchroParseUnitContext SchroParseUnitContext
static void libschroedinger_decode_frame_free(void *frame)
AVPixelFormat
Pixel format.
This structure stores compressed data.
AVFrame dec_frame
decoded picture
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)