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",