[MPlayer-dev-eng] [PATCH] ad_ffmpeg: basic support for planar formats.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu Oct 4 07:26:33 CEST 2012


Nicolas George <nicolas.george at normalesup.org> wrote:

>Upgrade to avcodec_decode_audio4().
>Planar formats are immediately converted to packet formats.
>A lot of optimizations are still possible.
>---
>libmpcodecs/ad_ffmpeg.c |   77
>++++++++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 70 insertions(+), 7 deletions(-)
>
>diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c
>index 53a89e5..c17c37b 100644
>--- a/libmpcodecs/ad_ffmpeg.c
>+++ b/libmpcodecs/ad_ffmpeg.c
>@@ -57,7 +57,7 @@ static int setup_format(sh_audio_t *sh_audio, const
>AVCodecContext *lavc_context
> {
>     int broken_srate = 0;
>     int samplerate    = lavc_context->sample_rate;
>-    int sample_format = samplefmt2affmt(lavc_context->sample_fmt);
>+    int sample_format =
>samplefmt2affmt(av_get_packed_sample_fmt(lavc_context->sample_fmt));
>     if (!sample_format)
>         sample_format = sh_audio->sample_format;
>     if(sh_audio->wf){
>@@ -169,10 +169,10 @@ static int init(sh_audio_t *sh_audio)
>       sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
> 
>   switch (lavc_context->sample_fmt) {
>-      case AV_SAMPLE_FMT_U8:
>-      case AV_SAMPLE_FMT_S16:
>-      case AV_SAMPLE_FMT_S32:
>-      case AV_SAMPLE_FMT_FLT:
>+      case AV_SAMPLE_FMT_U8:  case AV_SAMPLE_FMT_U8P:
>+      case AV_SAMPLE_FMT_S16: case AV_SAMPLE_FMT_S16P:
>+      case AV_SAMPLE_FMT_S32: case AV_SAMPLE_FMT_S32P:
>+      case AV_SAMPLE_FMT_FLT: case AV_SAMPLE_FMT_FLTP:
>           break;
>       default:
>           return 0;
>@@ -202,10 +202,66 @@ static int control(sh_audio_t *sh,int cmd,void*
>arg, ...)
>     return CONTROL_UNKNOWN;
> }
> 
>+static void copy_samples_planar(unsigned bps,
>+                                unsigned nb_samples, unsigned
>nb_channels,
>+                                unsigned char *dst, unsigned char
>**src)

I probably won't have time to review properly soon, so I'd say go ahead (and remove the FFmpeg lock from configure).
However I'd suggest to make this function av_always_inline, otherwise your trick with the switch probably will not work reliably.



More information about the MPlayer-dev-eng mailing list