44 #include <schroedinger/schro.h>
45 #include <schroedinger/schrodebug.h>
46 #include <schroedinger/schrovideoformat.h>
88 const uint8_t *buf,
int buf_size)
96 SchroBuffer *enc_buf =
NULL;
97 int next_pu_offset = 0;
98 unsigned char *in_buf;
101 parse_ctx->
buf[0] !=
'B' ||
102 parse_ctx->
buf[1] !=
'B' ||
103 parse_ctx->
buf[2] !=
'C' ||
104 parse_ctx->
buf[3] !=
'D')
107 next_pu_offset = (parse_ctx->
buf[5] << 24) +
108 (parse_ctx->
buf[6] << 16) +
109 (parse_ctx->
buf[7] << 8) +
112 if (next_pu_offset == 0 &&
113 SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->
buf[4]))
116 if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)
125 memcpy(in_buf, parse_ctx->
buf, next_pu_offset);
126 enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
128 enc_buf->priv = in_buf;
130 parse_ctx->
buf += next_pu_offset;
131 parse_ctx->
buf_size -= next_pu_offset;
145 for (idx = 0; idx < num_formats; ++idx)
158 schro_debug_set_level(avctx->
debug);
159 p_schro_params->
decoder = schro_decoder_new();
160 schro_decoder_set_skip_ratio(p_schro_params->
decoder, 1);
172 schro_frame_unref(frame);
180 p_schro_params->
format = schro_decoder_get_video_format(decoder);
184 p_schro_params->
format->height, 0, avctx) < 0) {
186 p_schro_params->
format->width, p_schro_params->
format->height);
197 "This codec currently only supports planar YUV 4:2:0, 4:2:2 "
198 "and 4:4:4 formats.\n");
207 void *
data,
int *got_frame,
211 int buf_size = avpkt->
size;
212 int64_t pts = avpkt->
pts;
217 SchroBuffer *enc_buf;
231 state = schro_decoder_push_end_of_stream(decoder);
241 if (!enc_buf->tag->value) {
245 AV_WN(64, enc_buf->tag->value, pts);
247 if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
248 SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
250 state = schro_decoder_push(decoder, enc_buf);
251 if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
259 state = schro_decoder_wait(decoder);
261 case SCHRO_DECODER_FIRST_ACCESS_UNIT:
265 case SCHRO_DECODER_NEED_BITS:
270 case SCHRO_DECODER_NEED_FRAME:
274 schro_decoder_add_output_picture(decoder, frame);
277 case SCHRO_DECODER_OK:
279 tag = schro_decoder_get_picture_tag(decoder);
280 frame = schro_decoder_pull(decoder);
289 framewithpts->
frame = frame;
295 case SCHRO_DECODER_EOS:
298 schro_decoder_reset(decoder);
302 case SCHRO_DECODER_ERROR:
312 if (framewithpts && framewithpts->
frame) {
318 memcpy(avframe->
data[0],
319 framewithpts->
frame->components[0].data,
320 framewithpts->
frame->components[0].length);
322 memcpy(avframe->
data[1],
323 framewithpts->
frame->components[1].data,
324 framewithpts->
frame->components[1].length);
326 memcpy(avframe->
data[2],
327 framewithpts->
frame->components[2].data,
328 framewithpts->
frame->components[2].length);
332 avframe->
linesize[0] = framewithpts->
frame->components[0].stride;
333 avframe->
linesize[1] = framewithpts->
frame->components[1].stride;
334 avframe->
linesize[2] = framewithpts->
frame->components[2].stride;
353 schro_decoder_free(p_schro_params->
decoder);
374 schro_decoder_reset(p_schro_params->
decoder);
380 .
name =
"libschroedinger",