40 #include <schroedinger/schro.h>
41 #include <schroedinger/schrodebug.h>
42 #include <schroedinger/schrovideoformat.h>
87 const uint8_t *buf,
int buf_size)
95 SchroBuffer *enc_buf =
NULL;
96 int next_pu_offset = 0;
97 unsigned char *in_buf;
100 parse_ctx->
buf[0] !=
'B' ||
101 parse_ctx->
buf[1] !=
'B' ||
102 parse_ctx->
buf[2] !=
'C' ||
103 parse_ctx->
buf[3] !=
'D')
106 next_pu_offset = (parse_ctx->
buf[5] << 24) +
107 (parse_ctx->
buf[6] << 16) +
108 (parse_ctx->
buf[7] << 8) +
111 if (next_pu_offset == 0 &&
112 SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->
buf[4]))
115 if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)
124 memcpy(in_buf, parse_ctx->
buf, next_pu_offset);
125 enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
127 enc_buf->priv = in_buf;
129 parse_ctx->
buf += next_pu_offset;
130 parse_ctx->
buf_size -= next_pu_offset;
144 for (idx = 0; idx < num_formats; ++idx)
157 schro_debug_set_level(avccontext->
debug);
158 p_schro_params->
decoder = schro_decoder_new();
159 schro_decoder_set_skip_ratio(p_schro_params->
decoder, 1);
171 schro_frame_unref(frame);
179 p_schro_params->
format = schro_decoder_get_video_format(decoder);
183 p_schro_params->
format->height, 0, avccontext) < 0) {
185 p_schro_params->
format->width, p_schro_params->
format->height);
196 "This codec currently only supports planar YUV 4:2:0, 4:2:2 "
197 "and 4:4:4 formats.\n");
206 void *
data,
int *got_frame,
210 int buf_size = avpkt->
size;
211 int64_t pts = avpkt->
pts;
216 SchroBuffer *enc_buf;
229 state = schro_decoder_push_end_of_stream(decoder);
239 if (!enc_buf->tag->value) {
243 AV_WN(64, enc_buf->tag->value, pts);
245 if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
246 SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
248 state = schro_decoder_push(decoder, enc_buf);
249 if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
257 state = schro_decoder_wait(decoder);
259 case SCHRO_DECODER_FIRST_ACCESS_UNIT:
263 case SCHRO_DECODER_NEED_BITS:
268 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) {
319 framewithpts->
frame->components[0].data,
320 framewithpts->
frame->components[0].length);
323 framewithpts->
frame->components[1].data,
324 framewithpts->
frame->components[1].length);
327 framewithpts->
frame->components[2].data,
328 framewithpts->
frame->components[2].length);
357 schro_decoder_free(p_schro_params->
decoder);
381 schro_decoder_reset(p_schro_params->
decoder);
387 .
name =
"libschroedinger",