summaryrefslogtreecommitdiffstats
path: root/libhb/hb.c
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-06-18 21:11:48 +0000
committerRodeo <[email protected]>2012-06-18 21:11:48 +0000
commitfc3e44b2ba28772fa559d39bd57b7a595a83292f (patch)
tree738449c393dcd8da6edf6881e53353b35e5c47b8 /libhb/hb.c
parent510564b19b5a6d7ac77091cd02ec9c557941399f (diff)
libhb: drop HB_INPUT_CH_LAYOUT_*
AV_CH_LAYOUT_* works for us, and as its usage becomes more widespread in libhb, translating between the two formats gets increasingly tedious. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4754 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/hb.c')
-rw-r--r--libhb/hb.c124
1 files changed, 38 insertions, 86 deletions
diff --git a/libhb/hb.c b/libhb/hb.c
index 64c03b3c4..0d881b888 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -203,94 +203,46 @@ hb_sws_get_context(int srcW, int srcH, enum PixelFormat srcFormat,
return ctx;
}
-int hb_ff_layout_xlat( int64_t ff_channel_layout, int channels )
+uint64_t hb_ff_layout_xlat(uint64_t ff_channel_layout, int nchannels)
{
- int hb_layout;
-
- switch( ff_channel_layout )
+ uint64_t hb_layout = ff_channel_layout;
+ if (!hb_layout ||
+ av_get_channel_layout_nb_channels(hb_layout) != nchannels)
{
- case AV_CH_LAYOUT_MONO:
- hb_layout = HB_INPUT_CH_LAYOUT_MONO;
- break;
- case AV_CH_LAYOUT_STEREO:
- case AV_CH_LAYOUT_STEREO_DOWNMIX:
- hb_layout = HB_INPUT_CH_LAYOUT_STEREO;
- break;
- case AV_CH_LAYOUT_SURROUND:
- hb_layout = HB_INPUT_CH_LAYOUT_3F;
- break;
- case AV_CH_LAYOUT_4POINT0:
- hb_layout = HB_INPUT_CH_LAYOUT_3F1R;
- break;
- case AV_CH_LAYOUT_2_2:
- case AV_CH_LAYOUT_QUAD:
- hb_layout = HB_INPUT_CH_LAYOUT_2F2R;
- break;
- case AV_CH_LAYOUT_5POINT0:
- case AV_CH_LAYOUT_5POINT0_BACK:
- hb_layout = HB_INPUT_CH_LAYOUT_3F2R;
- break;
- case AV_CH_LAYOUT_5POINT1:
- case AV_CH_LAYOUT_5POINT1_BACK:
- hb_layout = HB_INPUT_CH_LAYOUT_3F2R|HB_INPUT_CH_LAYOUT_HAS_LFE;
- break;
- case AV_CH_LAYOUT_7POINT0:
- hb_layout = HB_INPUT_CH_LAYOUT_3F4R;
- break;
- case AV_CH_LAYOUT_7POINT1:
- hb_layout = HB_INPUT_CH_LAYOUT_3F4R|HB_INPUT_CH_LAYOUT_HAS_LFE;
- break;
- default:
- hb_layout = HB_INPUT_CH_LAYOUT_STEREO;
- break;
- }
- // Now make sure the chosen layout agrees with the number of channels
- // ffmpeg tells us there are. It seems ffmpeg is sometimes confused
- // about this. So we will make a best guess based on the number
- // of channels.
- int chans = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( hb_layout );
- if( ff_channel_layout && chans == channels )
- {
- return hb_layout;
- }
- if( !ff_channel_layout )
- {
- hb_log( "No channel layout reported by Libav; guessing one from channel count." );
- }
- else
- {
- hb_log( "Channels reported by Libav (%d) != computed layout channels (%d). Guessing layout from channel count.", channels, chans );
- }
- switch( channels )
- {
- case 1:
- hb_layout = HB_INPUT_CH_LAYOUT_MONO;
- break;
- case 2:
- hb_layout = HB_INPUT_CH_LAYOUT_STEREO;
- break;
- case 3:
- hb_layout = HB_INPUT_CH_LAYOUT_3F;
- break;
- case 4:
- hb_layout = HB_INPUT_CH_LAYOUT_3F1R;
- break;
- case 5:
- hb_layout = HB_INPUT_CH_LAYOUT_3F2R;
- break;
- case 6:
- hb_layout = HB_INPUT_CH_LAYOUT_3F2R|HB_INPUT_CH_LAYOUT_HAS_LFE;
- break;
- case 7:
- hb_layout = HB_INPUT_CH_LAYOUT_3F4R;
- break;
- case 8:
- hb_layout = HB_INPUT_CH_LAYOUT_3F4R|HB_INPUT_CH_LAYOUT_HAS_LFE;
- break;
- default:
- hb_log( "Unsupported number of audio channels (%d).", channels );
- hb_layout = 0;
- break;
+ switch (nchannels)
+ {
+ // TODO: use av_get_default_channel_layout when available
+ case 1:
+ hb_layout = AV_CH_LAYOUT_MONO;
+ break;
+ case 2:
+ hb_layout = AV_CH_LAYOUT_STEREO;
+ break;
+ case 3:
+ hb_layout = AV_CH_LAYOUT_SURROUND;
+ break;
+ case 4:
+ hb_layout = AV_CH_LAYOUT_QUAD;
+ break;
+ case 5:
+ hb_layout = AV_CH_LAYOUT_5POINT0;
+ break;
+ case 6:
+ hb_layout = AV_CH_LAYOUT_5POINT1;
+ break;
+ case 7:
+ hb_layout = AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER;
+ break;
+ case 8:
+ hb_layout = AV_CH_LAYOUT_7POINT1;
+ break;
+ default:
+ // This will likely not sound very good ;)
+ hb_layout = AV_CH_LAYOUT_STEREO;
+ hb_error("hb_ff_layout_xlat: unsupported layout 0x%"PRIx64" with %d channels",
+ ff_channel_layout, nchannels);
+ break;
+ }
}
return hb_layout;
}