summaryrefslogtreecommitdiff
path: root/libavcodec/libschroedingerenc.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-10-12 18:54:52 +0200
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-10-14 11:24:55 +0200
commit6fdd4c678ac1ce0776f9645cd534209e5f1ae1e3 (patch)
treee5d05f7974c59ea346c19aaec87dd500f335e10b /libavcodec/libschroedingerenc.c
parent901f9c0a32985f48672fd68594111dc55d88a57a (diff)
libschroedinger: Properly use AVFrame API
Rather than copying data buffers around, allocate a proper frame, and use the standard AVFrame functions. This effectively makes the decoder capable of direct rendering. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/libschroedingerenc.c')
-rw-r--r--libavcodec/libschroedingerenc.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c
index ecf5e37d55..f390e4690e 100644
--- a/libavcodec/libschroedingerenc.c
+++ b/libavcodec/libschroedingerenc.c
@@ -32,6 +32,8 @@
#include <schroedinger/schrovideoformat.h>
#include "libavutil/attributes.h"
+#include "libavutil/imgutils.h"
+
#include "avcodec.h"
#include "internal.h"
#include "libschroedinger.h"
@@ -154,9 +156,9 @@ static av_cold int libschroedinger_encode_init(AVCodecContext *avctx)
p_schro_params->format->frame_rate_numerator = avctx->time_base.den;
p_schro_params->format->frame_rate_denominator = avctx->time_base.num;
- p_schro_params->frame_size = avpicture_get_size(avctx->pix_fmt,
- avctx->width,
- avctx->height);
+ p_schro_params->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
+ avctx->width,
+ avctx->height, 1);
if (!avctx->gop_size) {
schro_encoder_setting_set_double(p_schro_params->encoder,
@@ -233,17 +235,17 @@ static SchroFrame *libschroedinger_frame_from_data(AVCodecContext *avctx,
const AVFrame *frame)
{
SchroEncoderParams *p_schro_params = avctx->priv_data;
- SchroFrame *in_frame;
- /* Input line size may differ from what the codec supports. Especially
- * when transcoding from one format to another. So use avpicture_layout
- * to copy the frame. */
- in_frame = ff_create_schro_frame(avctx, p_schro_params->frame_format);
-
- if (in_frame)
- avpicture_layout((const AVPicture *)frame, avctx->pix_fmt,
- avctx->width, avctx->height,
- in_frame->components[0].data,
- p_schro_params->frame_size);
+ SchroFrame *in_frame = ff_create_schro_frame(avctx,
+ p_schro_params->frame_format);
+
+ if (in_frame) {
+ /* Copy input data to SchroFrame buffers (they match the ones
+ * referenced by the AVFrame stored in priv) */
+ if (av_frame_copy(in_frame->priv, frame) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to copy input data\n");
+ return NULL;
+ }
+ }
return in_frame;
}