[FFmpeg-cvslog] libavfilter: pass QP table through the filter chain
Michael Niedermayer
git at videolan.org
Fri Sep 7 05:30:08 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Sep 5 04:41:22 2012 +0200| [c9a0f9bf3ce263f1c0941070225e9a5f97b773bc] | committer: Michael Niedermayer
libavfilter: pass QP table through the filter chain
Any volunteers to port the pp and spp filters from libmpcodec?
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c9a0f9bf3ce263f1c0941070225e9a5f97b773bc
---
libavfilter/avcodec.c | 10 ++++++++++
libavfilter/avfilter.h | 2 ++
libavfilter/buffer.c | 23 ++++++++++++++++++++++-
libavfilter/version.h | 4 ++--
libavfilter/video.c | 1 +
5 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c
index f452303..95e30b3 100644
--- a/libavfilter/avcodec.c
+++ b/libavfilter/avcodec.c
@@ -42,6 +42,16 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
dst->video->top_field_first = src->top_field_first;
dst->video->key_frame = src->key_frame;
dst->video->pict_type = src->pict_type;
+ av_freep(&dst->video->qp_table);
+ dst->video->qp_table_linesize = 0;
+ if (src->qscale_table) {
+ int qsize = src->qstride ? src->qstride * ((src->height+15)/16) : (src->width+15)/16;
+ dst->video->qp_table = av_malloc(qsize);
+ if(!dst->video->qp_table)
+ return AVERROR(ENOMEM);
+ dst->video->qp_table_linesize = src->qstride;
+ memcpy(dst->video->qp_table, src->qscale_table, qsize);
+ }
break;
case AVMEDIA_TYPE_AUDIO:
dst->audio->sample_rate = src->sample_rate;
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index c0575ce..2e61ac5 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -131,6 +131,8 @@ typedef struct AVFilterBufferRefVideoProps {
int top_field_first; ///< field order
enum AVPictureType pict_type; ///< picture type of the frame
int key_frame; ///< 1 -> keyframe, 0-> not
+ int qp_table_linesize; ///< qp_table stride
+ int8_t *qp_table; ///< array of Quantization Parameters
} AVFilterBufferRefVideoProps;
/**
diff --git a/libavfilter/buffer.c b/libavfilter/buffer.c
index 3431c91..510dd2d 100644
--- a/libavfilter/buffer.c
+++ b/libavfilter/buffer.c
@@ -52,6 +52,11 @@ AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
return NULL;
}
*ret->video = *ref->video;
+ if (ref->video->qp_table) {
+ int qsize = ref->video->qp_table_linesize ? ref->video->qp_table_linesize * ((ref->video->h+15)/16) : (ref->video->w+15)/16;
+ ret->video->qp_table = av_malloc(qsize);
+ memcpy(ret->video->qp_table, ref->video->qp_table, qsize);
+ }
ret->extended_data = ret->data;
} else if (ref->type == AVMEDIA_TYPE_AUDIO) {
ret->audio = av_malloc(sizeof(AVFilterBufferRefAudioProps));
@@ -95,6 +100,7 @@ void ff_free_pool(AVFilterPool *pool)
av_freep(&picref->buf);
av_freep(&picref->audio);
+ av_assert0(!picref->video || !picref->video->qp_table);
av_freep(&picref->video);
av_freep(&pool->pic[i]);
pool->count--;
@@ -116,6 +122,9 @@ static void store_in_pool(AVFilterBufferRef *ref)
av_assert0(ref->buf->data[0]);
av_assert0(pool->refcount>0);
+ if (ref->video)
+ av_freep(&ref->video->qp_table);
+
if (pool->count == POOL_SIZE) {
AVFilterBufferRef *ref1 = pool->pic[0];
av_freep(&ref1->video);
@@ -155,6 +164,8 @@ void avfilter_unref_buffer(AVFilterBufferRef *ref)
}
if (ref->extended_data != ref->data)
av_freep(&ref->extended_data);
+ if (ref->video)
+ av_freep(&ref->video->qp_table);
av_freep(&ref->video);
av_freep(&ref->audio);
av_free(ref);
@@ -173,7 +184,17 @@ void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *s
dst->pos = src->pos;
switch (src->type) {
- case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break;
+ case AVMEDIA_TYPE_VIDEO: {
+ if (dst->video->qp_table)
+ av_freep(&dst->video->qp_table);
+ *dst->video = *src->video;
+ if (src->video->qp_table) {
+ int qsize = src->video->qp_table_linesize ? src->video->qp_table_linesize * ((src->video->h+15)/16) : (src->video->w+15)/16;
+ dst->video->qp_table = av_malloc(qsize);
+ memcpy(dst->video->qp_table, src->video->qp_table, qsize);
+ }
+ break;
+ }
case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break;
default: break;
}
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 6e9e520..8c9d4e1 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -29,8 +29,8 @@
#include "libavutil/avutil.h"
#define LIBAVFILTER_VERSION_MAJOR 3
-#define LIBAVFILTER_VERSION_MINOR 15
-#define LIBAVFILTER_VERSION_MICRO 104
+#define LIBAVFILTER_VERSION_MINOR 16
+#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 9ab8edb..14e7e72 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -55,6 +55,7 @@ AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, int perms, in
AVFilterBuffer *pic = picref->buf;
pool->pic[i] = NULL;
pool->count--;
+ av_assert0(!picref->video->qp_table);
picref->video->w = w;
picref->video->h = h;
picref->perms = full_perms;
More information about the ffmpeg-cvslog
mailing list