Re: [libav-devel] [PATCH 5/6] mlp: implement support for AVCodecContext.request_channel_layout.

2013-01-22 Thread Justin Ruggles
On 12/31/2012 09:33 AM, Tim Walker wrote:
> Also wrap usage of AVCodecContext.request_channels in FF_API_REQUEST_CHANNELS 
> directives.
> ---
>  libavcodec/mlp_parser.c |   29 +++--
>  libavcodec/mlpdec.c |   18 ++
>  2 files changed, 37 insertions(+), 10 deletions(-)

patch looks ok

-Justin

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 5/6] mlp: implement support for AVCodecContext.request_channel_layout.

2012-12-31 Thread Tim W.
On Dec 31, 2012, at 3:33 PM, Tim Walker  wrote:

> Also wrap usage of AVCodecContext.request_channels in FF_API_REQUEST_CHANNELS 
> directives.
> ---
> libavcodec/mlp_parser.c |   29 +++--
> libavcodec/mlpdec.c |   18 ++
> 2 files changed, 37 insertions(+), 10 deletions(-)

With this patch, request_channels always applies before request_channel_layout 
(in the rare case where both are set). I could easily reverse it 
(request_channel_layout, then request_channels) if someone thinks it's better 
though.

Tim
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 5/6] mlp: implement support for AVCodecContext.request_channel_layout.

2012-12-31 Thread Tim Walker
Also wrap usage of AVCodecContext.request_channels in FF_API_REQUEST_CHANNELS 
directives.
---
 libavcodec/mlp_parser.c |   29 +++--
 libavcodec/mlpdec.c |   18 ++
 2 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c
index 8c57840..7f6739f 100644
--- a/libavcodec/mlp_parser.c
+++ b/libavcodec/mlp_parser.c
@@ -322,28 +322,45 @@ static int mlp_parse(AVCodecParserContext *s,
 
 if (mh.stream_type == 0xbb) {
 /* MLP stream */
+#if FF_API_REQUEST_CHANNELS
 if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
 mh.num_substreams > 1) {
 avctx->channels   = 2;
 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
+} else
+#endif
+if (avctx->request_channel_layout == AV_CH_LAYOUT_STEREO &&
+mh.num_substreams > 1) {
+avctx->channels   = 2;
+avctx->channel_layout = AV_CH_LAYOUT_STEREO;
 } else {
 avctx->channels   = mh.channels_mlp;
 avctx->channel_layout = mh.channel_layout_mlp;
 }
 } else { /* mh.stream_type == 0xba */
 /* TrueHD stream */
+#if FF_API_REQUEST_CHANNELS
 if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
 mh.num_substreams > 1) {
 avctx->channels   = 2;
 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
-} else if (mh.channels_thd_stream2 &&
-   (avctx->request_channels <= 0 ||
-avctx->request_channels > mh.channels_thd_stream1)) {
-avctx->channels   = mh.channels_thd_stream2;
-avctx->channel_layout = mh.channel_layout_thd_stream2;
-} else {
+} else if (avctx->request_channels > 0 &&
+   avctx->request_channels <= mh.channels_thd_stream1) {
+avctx->channels   = mh.channels_thd_stream1;
+avctx->channel_layout = mh.channel_layout_thd_stream1;
+} else
+#endif
+if (avctx->request_channel_layout == AV_CH_LAYOUT_STEREO &&
+mh.num_substreams > 1) {
+avctx->channels   = 2;
+avctx->channel_layout = AV_CH_LAYOUT_STEREO;
+} else if (avctx->request_channel_layout == 
mh.channel_layout_thd_stream1 ||
+   !mh.channels_thd_stream2) {
 avctx->channels   = mh.channels_thd_stream1;
 avctx->channel_layout = mh.channel_layout_thd_stream1;
+} else {
+avctx->channels   = mh.channels_thd_stream2;
+avctx->channel_layout = mh.channel_layout_thd_stream2;
 }
 }
 
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 80ff401..c0174b4 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -445,14 +445,24 @@ static int read_restart_header(MLPDecodeContext *m, 
GetBitContext *gbp,
 return AVERROR_INVALIDDATA;
 }
 
-if (m->avctx->request_channels > 0
-&& s->max_channel + 1 >= m->avctx->request_channels
-&& substr < m->max_decoded_substream) {
+#if FF_API_REQUEST_CHANNELS
+if (m->avctx->request_channels > 0 &&
+m->avctx->request_channels <= s->max_channel + 1 &&
+m->max_decoded_substream > substr) {
 av_log(m->avctx, AV_LOG_DEBUG,
-   "Extracting %d channel downmix from substream %d. "
+   "Extracting %d-channel downmix from substream %d. "
"Further substreams will be skipped.\n",
s->max_channel + 1, substr);
 m->max_decoded_substream = substr;
+} else
+#endif
+if (m->avctx->request_channel_layout == s->ch_layout &&
+m->max_decoded_substream > substr) {
+av_log(m->avctx, AV_LOG_DEBUG,
+   "Extracting %d-channel downmix (0x%"PRIx64") from substream %d. 
"
+   "Further substreams will be skipped.\n",
+   s->max_channel + 1, s->ch_layout, substr);
+m->max_decoded_substream = substr;
 }
 
 s->noise_shift   = get_bits(gbp,  4);
-- 
1.7.10.2 (Apple Git-33)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel