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;
208 int64_t pts = avpkt->
pts;
213 SchroBuffer *enc_buf;
227 state = schro_decoder_push_end_of_stream(decoder);
237 if (!enc_buf->tag->value) {
241 AV_WN(64, enc_buf->tag->value, pts);
243 if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
244 SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
246 state = schro_decoder_push(decoder, enc_buf);
247 if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
255 state = schro_decoder_wait(decoder);
257 case SCHRO_DECODER_FIRST_ACCESS_UNIT:
261 case SCHRO_DECODER_NEED_BITS:
266 case SCHRO_DECODER_NEED_FRAME:
270 schro_decoder_add_output_picture(decoder, frame);
273 case SCHRO_DECODER_OK:
275 tag = schro_decoder_get_picture_tag(decoder);
276 frame = schro_decoder_pull(decoder);
291 case SCHRO_DECODER_EOS:
294 schro_decoder_reset(decoder);
298 case SCHRO_DECODER_ERROR:
308 if (framewithpts && framewithpts->
frame) {
314 memcpy(avframe->
data[0],
315 framewithpts->
frame->components[0].data,
316 framewithpts->
frame->components[0].length);
318 memcpy(avframe->
data[1],
319 framewithpts->
frame->components[1].data,
320 framewithpts->
frame->components[1].length);
322 memcpy(avframe->
data[2],
323 framewithpts->
frame->components[2].data,
324 framewithpts->
frame->components[2].length);
328 avframe->
linesize[0] = framewithpts->
frame->components[0].stride;
329 avframe->
linesize[1] = framewithpts->
frame->components[1].stride;
330 avframe->
linesize[2] = framewithpts->
frame->components[2].stride;
349 schro_decoder_free(p_schro_params->
decoder);
370 schro_decoder_reset(p_schro_params->
decoder);
376 .
name =
"libschroedinger",