view libmpcodecs/ad_dvdpcm.c @ 23289:786823779b67
Blackfin optimized YUV420 to RGB CSC Color Space Converters.
YUV2 -> RGB BGR for 565, 555 and 888 a.k.a. 24bit color.
Speed-up compared to C version compiled with -O3 187.28%
Patch by Marc Hoffman %mmh A pleasantst P com%
Original thread:
Date: May 9, 2007 2:46 AM
Subject: [FFmpeg-devel] PATCH BlackFin yuv2rgb color space conversion
author
gpoirier
date
Sun, 13 May 2007 19:22:32 +0000 (2007-05-13)
parents
815f03b7cee5
children
0f1b5b68af32
line source
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <stdio.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <stdlib.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <unistd.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include "config.h"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include "mp_msg.h"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include "help_mp.h"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include "ad_internal.h"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static ad_info_t info =
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 "Uncompressed DVD/VOB LPCM audio decoder",
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 "dvdpcm",
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 "Nick Kurshev",
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 "A'rpi",
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 ""
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 };
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 LIBAD_EXTERN(dvdpcm)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static int init(sh_audio_t *sh)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* DVD PCM Audio:*/
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->i_bps = 0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if(sh->codecdata_len==3){
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // we have LPCM header:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 unsigned char h=sh->codecdata[1];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->channels=1+(h&7);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 switch((h>>4)&3){
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 case 0: sh->samplerate=48000;break;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 case 1: sh->samplerate=96000;break;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 case 2: sh->samplerate=44100;break;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 case 3: sh->samplerate=32000;break;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 switch ((h >> 6) & 3) {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 case 0:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->sample_format = AF_FORMAT_S16_BE;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->samplesize = 2;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 break;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 case 1:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_SamplesWanted);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->i_bps = sh->channels * sh->samplerate * 5 / 2;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 case 2:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->sample_format = AF_FORMAT_S24_BE;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->samplesize = 3;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 break;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 default:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->sample_format = AF_FORMAT_S16_BE;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->samplesize = 2;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 } else {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // use defaults:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->channels=2;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->samplerate=48000;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->sample_format = AF_FORMAT_S16_BE;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->samplesize = 2;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (!sh->i_bps)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->i_bps = sh->samplesize * sh->channels * sh->samplerate;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 return 1;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static int preinit(sh_audio_t *sh)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sh->audio_out_minsize=2048;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 return 1;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static void uninit(sh_audio_t *sh)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 int skip;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 switch(cmd)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 case ADCTRL_SKIP_FRAME:
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 skip=sh->i_bps/16;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 skip=skip&(~3);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 demux_read_data(sh->ds,NULL,skip);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 return CONTROL_TRUE;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 return CONTROL_UNKNOWN;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 int j,len;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (sh_audio->samplesize == 3) {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (((sh_audio->codecdata[1] >> 6) & 3) == 1) {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // 20 bit
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // not sure if the "& 0xf0" and "<< 4" are the right way around
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // can somebody clarify?
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 for (j = 0; j < minlen; j += 12) {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 char tmp[10];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 len = demux_read_data(sh_audio->ds, tmp, 10);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (len < 10) break;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // first sample
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 0] = tmp[0];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 1] = tmp[1];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 2] = tmp[8] & 0xf0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // second sample
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 3] = tmp[2];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 4] = tmp[3];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 5] = tmp[8] << 4;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // third sample
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 6] = tmp[4];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 7] = tmp[5];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 8] = tmp[9] & 0xf0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // fourth sample
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 9] = tmp[6];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 10] = tmp[7];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 11] = tmp[9] << 4;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 len = j;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 } else {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // 24 bit
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 for (j = 0; j < minlen; j += 12) {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 char tmp[12];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 len = demux_read_data(sh_audio->ds, tmp, 12);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (len < 12) break;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // first sample
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 0] = tmp[0];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 1] = tmp[1];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 2] = tmp[8];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // second sample
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 3] = tmp[2];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 4] = tmp[3];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 5] = tmp[9];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // third sample
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 6] = tmp[4];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 7] = tmp[5];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 8] = tmp[10];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 // fourth sample
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 9] = tmp[6];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 10] = tmp[7];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 buf[j + 11] = tmp[11];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 len = j;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 } else
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 len=demux_read_data(sh_audio->ds,buf,(minlen+3)&(~3));
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 return len;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }