Skip to content

Commit

Permalink
[lavcodec/audio] Enable vorbis decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
mean committed Oct 15, 2016
1 parent 8e260dc commit 4841380
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
69 changes: 65 additions & 4 deletions avidemux_plugins/ADM_audioDecoders/ADM_ad_lav/ADM_ad_lav.cpp
Expand Up @@ -60,8 +60,52 @@ class ADM_AudiocoderLavcodec : public ADM_Audiocodec
virtual uint32_t getOutputFrequency(void) {return outputFrequency;}

};


/**
*
* @param l
* @param src
* @param dst
* @return
*/
static int xiphEncode(int l, uint8_t *src, uint8_t *dstOrg)
{
int outLen=1;
int length[3];
uint8_t *dst=dstOrg;
ADM_info("insize=%d\n",l);
*dst++=0x2;
for(int i=0;i<3;i++)
{
length[i]=(src[3]<<24)+(src[2]<<16)+(src[1]<<8)+src[0];
src+=4;
printf("Packet %d size %d\n",i,length[i]);
// encode length
if(i!=2)
{
int encode=length[i];
while(encode>=255)
{
*dst++=0xff;
encode-=0xff;
}
*dst++=encode;
}
}
// now copy blocks
for(int i=0;i<3;i++)
{
int block=length[i];
memcpy(dst,src,block);
src+=block;
dst+=block;
}
int outSize= (int)(dst-dstOrg);
ADM_info("OutSize=%d\n",outSize);
return outSize;



}


// Supported formats + declare our plugin
Expand All @@ -81,6 +125,7 @@ static ad_supportedFormat Formats[]={
{WAV_AAC,AD_LOW_QUAL}, // libfaad preferred ???
{0x706D,AD_LOW_QUAL},
{WAV_EAC3,AD_MEDIUM_QUAL},
{WAV_OGG_VORBIS,AD_HIGH_QUAL},
};

DECLARE_AUDIO_DECODER(ADM_AudiocoderLavcodec, // Class
Expand Down Expand Up @@ -156,6 +201,10 @@ DECLARE_AUDIO_DECODER(ADM_AudiocoderLavcodec, // Class
codecID = AV_CODEC_ID_EAC3;
_blockalign = 1;
break;
case WAV_OGG_VORBIS:
codecID = AV_CODEC_ID_VORBIS;
_blockalign = 1;
break;
case WAV_AAC:
case 0x706D:
codecID = AV_CODEC_ID_AAC;
Expand All @@ -179,8 +228,20 @@ DECLARE_AUDIO_DECODER(ADM_AudiocoderLavcodec, // Class
_context->bit_rate = info->byterate*8;
_context->sample_fmt=AV_SAMPLE_FMT_FLT;
_context->request_sample_fmt=AV_SAMPLE_FMT_FLT;
_context->extradata=(uint8_t *)d;
_context->extradata_size=(int)l;

if(fourcc==WAV_OGG_VORBIS)
{
// Need to translate from adm to xiph
int xiphLen=(int)l+(l/255)+4+5;
uint8_t *xiph=new uint8_t[xiphLen];
xiphLen=xiphEncode(l,d,xiph);
_context->extradata=xiph;
_context->extradata_size=xiphLen;
}else
{
_context->extradata=(uint8_t *)d;
_context->extradata_size=(int)l;
}

if (!_blockalign)
{
Expand Down
2 changes: 1 addition & 1 deletion cmake/admFFmpegBuild.cmake
Expand Up @@ -23,7 +23,7 @@ set(FFMPEG_DECODERS aac ac3 eac3 adpcm_ima_amv amv bmp cinepak cyuv dca d
hevc huffyuv mjpeg
mjpegb mpeg2video mpeg4 msmpeg4v2 msmpeg4v3 msvideo1 nellymoser png qdm2 rawvideo snow
svq3 theora tscc mp2 mp3 mp2_float mp3_float
vc1 vp3 vp6 vp6a vp6f vp8 vp9 wmapro wmav2 wmv1 wmv2 wmv3 cscd lagarith flac)
vc1 vp3 vp6 vp6a vp6f vp8 vp9 wmapro wmav2 wmv1 wmv2 wmv3 cscd lagarith flac vorbis)
set(FFMPEG_ENCODERS ac3 ac3_float dvvideo ffv1 ffvhuff flv h263 huffyuv mjpeg mp2 mpeg1video mpeg2video mpeg4 snow aac dca flac)
set(FFMPEG_MUXERS flv matroska mpeg1vcd mpeg2dvd mpeg2svcd mpegts mov mp4 psp webm)
set(FFMPEG_PARSERS ac3 h263 h264 hevc mpeg4video)
Expand Down

0 comments on commit 4841380

Please sign in to comment.