40 #include <schroedinger/schro.h>
41 #include <schroedinger/schrodebug.h>
42 #include <schroedinger/schrovideoformat.h>
92 SchroBuffer *enc_buf =
NULL;
93 int next_pu_offset = 0;
94 unsigned char *in_buf;
97 parse_ctx->
buf[0] !=
'B' ||
98 parse_ctx->
buf[1] !=
'B' ||
99 parse_ctx->
buf[2] !=
'C' ||
100 parse_ctx->
buf[3] !=
'D')
103 next_pu_offset = (parse_ctx->
buf[5] << 24) +
104 (parse_ctx->
buf[6] << 16) +
105 (parse_ctx->
buf[7] << 8) +
108 if (next_pu_offset == 0 &&
109 SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->
buf[4]))
112 if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)
121 memcpy(in_buf, parse_ctx->
buf, next_pu_offset);
122 enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
124 enc_buf->priv = in_buf;
126 parse_ctx->
buf += next_pu_offset;
127 parse_ctx->
buf_size -= next_pu_offset;
141 for (idx = 0; idx < num_formats; ++idx)
154 schro_debug_set_level(avctx->
debug);
155 p_schro_params->
decoder = schro_decoder_new();
156 schro_decoder_set_skip_ratio(p_schro_params->
decoder, 1);
168 schro_frame_unref(frame);
176 p_schro_params->
format = schro_decoder_get_video_format(decoder);
180 p_schro_params->
format->height, 0, avctx) < 0) {
182 p_schro_params->
format->width, p_schro_params->
format->height);
193 "This codec currently only supports planar YUV 4:2:0, 4:2:2 "
194 "and 4:4:4 formats.\n");
203 void *
data,
int *got_frame,
207 int buf_size = avpkt->
size;
213 SchroBuffer *enc_buf;
227 state = schro_decoder_push_end_of_stream(decoder);
237 if (!enc_buf->tag->value) {
241 AV_WN(64, enc_buf->tag->value, pts);
243 if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
244 SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
246 state = schro_decoder_push(decoder, enc_buf);
247 if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
255 state = schro_decoder_wait(decoder);
257 case SCHRO_DECODER_FIRST_ACCESS_UNIT:
261 case SCHRO_DECODER_NEED_BITS:
266 case SCHRO_DECODER_NEED_FRAME:
272 schro_decoder_add_output_picture(decoder, frame);
275 case SCHRO_DECODER_OK:
277 tag = schro_decoder_get_picture_tag(decoder);
278 frame = schro_decoder_pull(decoder);
293 case SCHRO_DECODER_EOS:
296 schro_decoder_reset(decoder);
300 case SCHRO_DECODER_ERROR:
310 if (framewithpts && framewithpts->
frame) {
316 memcpy(avframe->
data[0],
317 framewithpts->
frame->components[0].data,
318 framewithpts->
frame->components[0].length);
320 memcpy(avframe->
data[1],
321 framewithpts->
frame->components[1].data,
322 framewithpts->
frame->components[1].length);
324 memcpy(avframe->
data[2],
325 framewithpts->
frame->components[2].data,
326 framewithpts->
frame->components[2].length);
330 avframe->
linesize[0] = framewithpts->
frame->components[0].stride;
331 avframe->
linesize[1] = framewithpts->
frame->components[1].stride;
332 avframe->
linesize[2] = framewithpts->
frame->components[2].stride;
351 schro_decoder_free(p_schro_params->
decoder);
372 schro_decoder_reset(p_schro_params->
decoder);
378 .
name =
"libschroedinger",
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
SchroChromaFormat schro_pix_fmt
memory handling functions
static av_cold int init(AVCodecContext *avctx)
SchroFrame * ff_create_schro_frame(AVCodecContext *avctx, SchroFrameFormat schro_frame_fmt)
Create a Schro frame based on the dimensions and frame format passed.
SchroVideoFormat * format
Schroedinger video format.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_cold int libschroedinger_decode_init(AVCodecContext *avctx)
static SchroBuffer * find_next_parse_unit(SchroParseUnitContext *parse_ctx)
static enum AVPixelFormat get_chroma_format(SchroChromaFormat schro_pix_fmt)
Returns FFmpeg 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.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
SchroDecoder * decoder
decoder handle
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
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. ...
AVCodec ff_libschroedinger_decoder
const char * name
Name of the codec implementation.
static av_cold int libschroedinger_decode_close(AVCodecContext *avctx)
static void libschroedinger_flush(AVCodecContext *avctx)
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.
av_cold void ff_schro_queue_init(FFSchroQueue *queue)
Initialise the queue.
A simple queue implementation used in libschroedinger.
static const chunk_decoder decoder[8]
int width
picture width / height.
libschroedinger decoder private data
SchroFrame and Pts relation.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static int libschroedinger_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
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.
static int64_t pts
Global timestamp for the audio frames.
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.
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
common internal api header.
static const struct @69 schro_pixel_format_map[]
static void libschroedinger_decode_frame_free(void *frame)
static void libschroedinger_handle_first_access_unit(AVCodecContext *avctx)
AVPixelFormat
Pixel format.
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...