[FFmpeg-devel] [PATCH 2/5] pp: add pp_get_context2().
Michael Niedermayer
michaelni at gmx.at
Sat Nov 17 19:33:21 CET 2012
On Sat, Nov 17, 2012 at 01:07:10PM +0100, Clément Bœsch wrote:
> ---
> 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);
Is this neccessary ?
wouldnt simply adding a PP_CPU_CAPS_AUTO achive nearly the same ?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 1
"Used only once" - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121117/51684bce/attachment.asc>
More information about the ffmpeg-devel
mailing list