[FFmpeg-devel] [PATCH 2/5] pp: add pp_get_context2().
Clément Bœsch
ubitux at gmail.com
Sat Nov 17 13:07:10 CET 2012
---
libpostproc/postprocess.c | 42 +++++++++++++++++++++++++++++++++++++-----
libpostproc/postprocess.h | 3 ++-
libpostproc/version.h | 2 +-
3 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c
index b4ae866..21238fd 100644
--- a/libpostproc/postprocess.c
+++ b/libpostproc/postprocess.c
@@ -88,6 +88,7 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks
#include "postprocess.h"
#include "postprocess_internal.h"
#include "libavutil/avstring.h"
+#include "libavutil/pixdesc.h"
unsigned postproc_version(void)
{
@@ -586,11 +587,11 @@ static inline void postProcess(const uint8_t src[], int srcStride, uint8_t dst[]
#if CONFIG_RUNTIME_CPUDETECT
#if ARCH_X86 && HAVE_INLINE_ASM
// ordered per speed fastest first
- if (c->cpuCaps & PP_CPU_CAPS_MMX2) pp = postProcess_MMX2;
- else if (c->cpuCaps & PP_CPU_CAPS_3DNOW) pp = postProcess_3DNow;
- else if (c->cpuCaps & PP_CPU_CAPS_MMX) pp = postProcess_MMX;
+ if (c->cpuCaps & AV_CPU_FLAG_MMXEXT) pp = postProcess_MMX2;
+ else if (c->cpuCaps & AV_CPU_FLAG_3DNOW) pp = postProcess_3DNow;
+ else if (c->cpuCaps & AV_CPU_FLAG_MMX) pp = postProcess_MMX;
#elif HAVE_ALTIVEC
- if (c->cpuCaps & PP_CPU_CAPS_ALTIVEC) pp = postProcess_altivec;
+ if (c->cpuCaps & AV_CPU_FLAG_ALTIVEC) pp = postProcess_altivec;
#endif
#else /* CONFIG_RUNTIME_CPUDETECT */
#if HAVE_MMXEXT_INLINE
@@ -896,7 +897,6 @@ pp_context *pp_get_context(int width, int height, int cpuCaps){
memset(c, 0, sizeof(PPContext));
c->av_class = &av_codec_context_class;
- c->cpuCaps= cpuCaps;
if(cpuCaps&PP_FORMAT){
c->hChromaSubSample= cpuCaps&0x3;
c->vChromaSubSample= (cpuCaps>>4)&0x3;
@@ -904,6 +904,11 @@ pp_context *pp_get_context(int width, int height, int cpuCaps){
c->hChromaSubSample= 1;
c->vChromaSubSample= 1;
}
+ c->cpuCaps = 0;
+ if (cpuCaps & PP_CPU_CAPS_MMX) c->cpuCaps |= AV_CPU_FLAG_MMX;
+ if (cpuCaps & PP_CPU_CAPS_MMX2) c->cpuCaps |= AV_CPU_FLAG_MMXEXT;
+ if (cpuCaps & PP_CPU_CAPS_3DNOW) c->cpuCaps |= AV_CPU_FLAG_3DNOW;
+ if (cpuCaps & PP_CPU_CAPS_ALTIVEC) c->cpuCaps |= AV_CPU_FLAG_ALTIVEC;
reallocBuffers(c, width, height, stride, qpStride);
@@ -912,6 +917,33 @@ pp_context *pp_get_context(int width, int height, int cpuCaps){
return c;
}
+pp_context *pp_get_context2(int width, int height, int pixfmt)
+{
+ PPContext *c;
+ int stride = FFALIGN(width, 16); //assumed / will realloc if needed
+ int qpStride = (width+15)/16 + 2; //assumed / will realloc if needed
+ const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pixfmt);
+
+ if (!pix_desc) {
+ av_log(NULL, AV_LOG_ERROR, "Unknown pixel format %d\n", pixfmt);
+ return NULL;
+ }
+
+ c = av_mallocz(sizeof(*c));
+ if (!c)
+ return NULL;
+
+ c->cpuCaps = av_get_cpu_flags();
+ c->av_class = &av_codec_context_class;
+ c->hChromaSubSample = pix_desc->log2_chroma_w;
+ c->vChromaSubSample = pix_desc->log2_chroma_h;
+
+ reallocBuffers(c, width, height, stride, qpStride);
+
+ c->frameNum = -1;
+ return c;
+}
+
void pp_free_context(void *vc){
PPContext *c = (PPContext*)vc;
int i;
diff --git a/libpostproc/postprocess.h b/libpostproc/postprocess.h
index 623b3b5..af6d55a 100644
--- a/libpostproc/postprocess.h
+++ b/libpostproc/postprocess.h
@@ -77,7 +77,8 @@ void pp_postprocess(const uint8_t * src[3], const int srcStride[3],
pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality);
void pp_free_mode(pp_mode *mode);
-pp_context *pp_get_context(int width, int height, int flags);
+attribute_deprecated pp_context *pp_get_context(int width, int height, int flags);
+pp_context *pp_get_context2(int width, int height, int pixfmt);
void pp_free_context(pp_context *ppContext);
#define PP_CPU_CAPS_MMX 0x80000000
diff --git a/libpostproc/version.h b/libpostproc/version.h
index f634630..35e1772 100644
--- a/libpostproc/version.h
+++ b/libpostproc/version.h
@@ -30,7 +30,7 @@
#ifndef LIBPOSTPROC_VERSION_MAJOR
#define LIBPOSTPROC_VERSION_MAJOR 52
-#define LIBPOSTPROC_VERSION_MINOR 1
+#define LIBPOSTPROC_VERSION_MINOR 2
#define LIBPOSTPROC_VERSION_MICRO 100
#endif
--
1.8.0
More information about the ffmpeg-devel
mailing list