39 #include <schroedinger/schro.h>
40 #include <schroedinger/schrodebug.h>
41 #include <schroedinger/schrovideoformat.h>
77 const uint8_t *buf,
int buf_size)
85 SchroBuffer *enc_buf =
NULL;
86 int next_pu_offset = 0;
87 unsigned char *in_buf;
90 parse_ctx->
buf[0] !=
'B' ||
91 parse_ctx->
buf[1] !=
'B' ||
92 parse_ctx->
buf[2] !=
'C' ||
93 parse_ctx->
buf[3] !=
'D')
96 next_pu_offset = (parse_ctx->
buf[5] << 24) +
97 (parse_ctx->
buf[6] << 16) +
98 (parse_ctx->
buf[7] << 8) +
101 if (next_pu_offset == 0 &&
102 SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->
buf[4]))
105 if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)
109 memcpy(in_buf, parse_ctx->
buf, next_pu_offset);
110 enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
112 enc_buf->priv = in_buf;
114 parse_ctx->
buf += next_pu_offset;
115 parse_ctx->
buf_size -= next_pu_offset;
129 for (idx = 0; idx < num_formats; ++idx)
142 schro_debug_set_level(avccontext->
debug);
143 p_schro_params->
decoder = schro_decoder_new();
144 schro_decoder_set_skip_ratio(p_schro_params->
decoder, 1);
162 schro_frame_unref(frame);
170 p_schro_params->
format = schro_decoder_get_video_format(decoder);
174 0, avccontext) < 0) {
176 p_schro_params->
format->width, p_schro_params->
format->height);
187 "This codec currently only supports planar YUV 4:2:0, 4:2:2 "
188 "and 4:4:4 formats.\n");
203 void *
data,
int *data_size,
206 const uint8_t *buf = avpkt->
data;
207 int buf_size = avpkt->
size;
212 SchroBuffer *enc_buf;
224 state = schro_decoder_push_end_of_stream(decoder);
233 if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
234 SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
236 state = schro_decoder_push(decoder, enc_buf);
237 if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
245 state = schro_decoder_wait(decoder);
247 case SCHRO_DECODER_FIRST_ACCESS_UNIT:
251 case SCHRO_DECODER_NEED_BITS:
256 case SCHRO_DECODER_NEED_FRAME:
260 schro_decoder_add_output_picture(decoder, frame);
263 case SCHRO_DECODER_OK:
265 frame = schro_decoder_pull(decoder);
271 case SCHRO_DECODER_EOS:
274 schro_decoder_reset(decoder);
278 case SCHRO_DECODER_ERROR:
290 frame->components[0].data,
291 frame->components[0].length);
294 frame->components[1].data,
295 frame->components[1].length);
298 frame->components[2].data,
299 frame->components[2].length);
319 schro_decoder_free(p_schro_params->
decoder);
342 schro_decoder_reset(p_schro_params->
decoder);
348 .
name =
"libschroedinger",