summaryrefslogtreecommitdiff
path: root/libavcodec/libschroedinger.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/libschroedinger.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/libschroedinger.c')
-rw-r--r--libavcodec/libschroedinger.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/libavcodec/libschroedinger.c b/libavcodec/libschroedinger.c
index 157433ea95..16e0fe89b9 100644
--- a/libavcodec/libschroedinger.c
+++ b/libavcodec/libschroedinger.c
@@ -26,6 +26,7 @@
#include "libavutil/attributes.h"
#include "libavutil/mem.h"
#include "libschroedinger.h"
+#include "internal.h"
static const SchroVideoFormatInfo ff_schro_video_format_info[] = {
{ 640, 480, 24000, 1001},
@@ -167,19 +168,14 @@ int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt,
static void free_schro_frame(SchroFrame *frame, void *priv)
{
- AVPicture *p_pic = priv;
-
- if (!p_pic)
- return;
-
- avpicture_free(p_pic);
- av_freep(&p_pic);
+ AVFrame *p_pic = priv;
+ av_frame_free(&p_pic);
}
SchroFrame *ff_create_schro_frame(AVCodecContext *avctx,
SchroFrameFormat schro_frame_fmt)
{
- AVPicture *p_pic;
+ AVFrame *p_pic;
SchroFrame *p_frame;
int y_width, uv_width;
int y_height, uv_height;
@@ -190,10 +186,15 @@ SchroFrame *ff_create_schro_frame(AVCodecContext *avctx,
uv_width = y_width >> (SCHRO_FRAME_FORMAT_H_SHIFT(schro_frame_fmt));
uv_height = y_height >> (SCHRO_FRAME_FORMAT_V_SHIFT(schro_frame_fmt));
- p_pic = av_mallocz(sizeof(AVPicture));
+ p_pic = av_frame_alloc();
if (!p_pic)
return NULL;
- avpicture_alloc(p_pic, avctx->pix_fmt, y_width, y_height);
+
+ if (ff_get_buffer(avctx, p_pic, AV_GET_BUFFER_FLAG_REF) < 0) {
+ av_frame_free(&p_pic);
+ av_log(avctx, AV_LOG_ERROR, "Unable to allocate buffer\n");
+ return NULL;
+ }
p_frame = schro_frame_new();
p_frame->format = schro_frame_fmt;