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;
228 state = schro_decoder_push_end_of_stream(decoder);
238 if (!enc_buf->tag->value) {
242 AV_WN(64, enc_buf->tag->value, pts);
244 if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
245 SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
247 state = schro_decoder_push(decoder, enc_buf);
248 if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
256 state = schro_decoder_wait(decoder);
258 case SCHRO_DECODER_FIRST_ACCESS_UNIT:
262 case SCHRO_DECODER_NEED_BITS:
267 case SCHRO_DECODER_NEED_FRAME:
273 schro_decoder_add_output_picture(decoder, frame);
276 case SCHRO_DECODER_OK:
278 tag = schro_decoder_get_picture_tag(decoder);
279 frame = schro_decoder_pull(decoder);
294 case SCHRO_DECODER_EOS:
297 schro_decoder_reset(decoder);
301 case SCHRO_DECODER_ERROR:
311 if (framewithpts && framewithpts->
frame && framewithpts->
frame->components[0].stride) {
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);
329 avframe->
pts = framewithpts->
pts;
335 avframe->
linesize[0] = framewithpts->
frame->components[0].stride;
336 avframe->
linesize[1] = framewithpts->
frame->components[1].stride;
337 avframe->
linesize[2] = framewithpts->
frame->components[2].stride;
347 if (framewithpts && framewithpts->
frame)
358 schro_decoder_free(p_schro_params->
decoder);
379 schro_decoder_reset(p_schro_params->
decoder);
385 .
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 decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
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...
static av_cold int end(AVCodecContext *avctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
SchroDecoder * decoder
decoder handle
static const struct @86 schro_pixel_format_map[]
#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
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.
attribute_deprecated int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
#define FF_ENABLE_DEPRECATION_WARNINGS
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...