#include "internal.h"
#include "libschroedinger.h"
-#undef NDEBUG
-#include <assert.h>
-
-
#include <schroedinger/schro.h>
#include <schroedinger/schrodebug.h>
#include <schroedinger/schrovideoformat.h>
/** end of sequence pulled */
int eos_pulled;
-
- /** decoded picture */
- AVFrame dec_frame;
} SchroDecoderParams;
typedef struct SchroParseUnitContext {
return;
}
- avctx->time_base.den = p_schro_params->format->frame_rate_numerator;
- avctx->time_base.num = p_schro_params->format->frame_rate_denominator;
+ avctx->framerate.num = p_schro_params->format->frame_rate_numerator;
+ avctx->framerate.den = p_schro_params->format->frame_rate_denominator;
}
static int libschroedinger_decode_frame(AVCodecContext *avctx,
SchroDecoder *decoder = p_schro_params->decoder;
SchroBuffer *enc_buf;
SchroFrame* frame;
+ AVFrame *avframe = data;
int state;
int go = 1;
int outer = 1;
SchroParseUnitContext parse_ctx;
LibSchroFrameContext *framewithpts = NULL;
+ int ret;
*got_frame = 0;
/* Decoder needs a frame - create one and push it in. */
frame = ff_create_schro_frame(avctx,
p_schro_params->frame_format);
+ if (!frame)
+ return AVERROR(ENOMEM);
schro_decoder_add_output_picture(decoder, frame);
break;
/* Grab next frame to be returned from the top of the queue. */
framewithpts = ff_schro_queue_pop(&p_schro_params->dec_frame_queue);
- if (framewithpts && framewithpts->frame) {
- if (p_schro_params->dec_frame.data[0])
- avctx->release_buffer(avctx, &p_schro_params->dec_frame);
- if (ff_get_buffer(avctx, &p_schro_params->dec_frame) < 0) {
+ if (framewithpts && framewithpts->frame && framewithpts->frame->components[0].stride) {
+ if ((ret = ff_get_buffer(avctx, avframe, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Unable to allocate buffer\n");
- return AVERROR(ENOMEM);
+ goto end;
}
- memcpy(p_schro_params->dec_frame.data[0],
+ memcpy(avframe->data[0],
framewithpts->frame->components[0].data,
framewithpts->frame->components[0].length);
- memcpy(p_schro_params->dec_frame.data[1],
+ memcpy(avframe->data[1],
framewithpts->frame->components[1].data,
framewithpts->frame->components[1].length);
- memcpy(p_schro_params->dec_frame.data[2],
+ memcpy(avframe->data[2],
framewithpts->frame->components[2].data,
framewithpts->frame->components[2].length);
/* Fill frame with current buffer data from Schroedinger. */
- p_schro_params->dec_frame.format = -1; /* Unknown -1 */
- p_schro_params->dec_frame.width = framewithpts->frame->width;
- p_schro_params->dec_frame.height = framewithpts->frame->height;
- p_schro_params->dec_frame.pkt_pts = framewithpts->pts;
- p_schro_params->dec_frame.linesize[0] = framewithpts->frame->components[0].stride;
- p_schro_params->dec_frame.linesize[1] = framewithpts->frame->components[1].stride;
- p_schro_params->dec_frame.linesize[2] = framewithpts->frame->components[2].stride;
-
- *(AVFrame*)data = p_schro_params->dec_frame;
- *got_frame = 1;
+ avframe->pts = framewithpts->pts;
+#if FF_API_PKT_PTS
+FF_DISABLE_DEPRECATION_WARNINGS
+ avframe->pkt_pts = avframe->pts;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ avframe->linesize[0] = framewithpts->frame->components[0].stride;
+ avframe->linesize[1] = framewithpts->frame->components[1].stride;
+ avframe->linesize[2] = framewithpts->frame->components[2].stride;
- /* Now free the frame resources. */
- libschroedinger_decode_frame_free(framewithpts->frame);
- av_free(framewithpts);
+ *got_frame = 1;
} else {
data = NULL;
*got_frame = 0;
}
- return buf_size;
+ ret = buf_size;
+end:
+ /* Now free the frame resources. */
+ if (framewithpts && framewithpts->frame)
+ libschroedinger_decode_frame_free(framewithpts->frame);
+ av_freep(&framewithpts);
+ return ret;
}
schro_decoder_free(p_schro_params->decoder);
av_freep(&p_schro_params->format);
- if (p_schro_params->dec_frame.data[0])
- avctx->release_buffer(avctx, &p_schro_params->dec_frame);
-
/* Free data in the output frame queue. */
ff_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
AVCodec ff_libschroedinger_decoder = {
.name = "libschroedinger",
+ .long_name = NULL_IF_CONFIG_SMALL("libschroedinger Dirac 2.2"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_DIRAC,
.priv_data_size = sizeof(SchroDecoderParams),
.init = libschroedinger_decode_init,
.close = libschroedinger_decode_close,
.decode = libschroedinger_decode_frame,
- .capabilities = CODEC_CAP_DELAY,
+ .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
.flush = libschroedinger_flush,
- .long_name = NULL_IF_CONFIG_SMALL("libschroedinger Dirac 2.2"),
+ .wrapper_name = "libschroedinger",
};