X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;ds=sidebyside;f=cinelerra-5.1%2Fcinelerra%2Ffileac3.C;h=63654f32ff430818dc459d8bd24ce97bfe43cbe4;hb=300cfc94af29dda96d2f5e5e7b64ab559452fd8d;hp=eef48e63bb2447d08fa7b0e29411abaf73fa89bf;hpb=853b81c6d430bd41037984ecc95fd304fd98964e;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/fileac3.C b/cinelerra-5.1/cinelerra/fileac3.C index eef48e63..63654f32 100644 --- a/cinelerra-5.1/cinelerra/fileac3.C +++ b/cinelerra-5.1/cinelerra/fileac3.C @@ -2,6 +2,7 @@ /* * CINELERRA * Copyright (C) 2008 Adam Williams + * Copyright (C) 2003-2016 Cinelerra CV contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - +#ifdef HAVE_LIBZMPEG #include #include #include @@ -141,24 +142,39 @@ int FileAC3::open_file(int rd, int wr) int channels = asset->channels; int sample_rate = asset->sample_rate; int64_t layout = get_channel_layout(channels); + AVChannelLayout ch_layout; + av_channel_layout_default(&ch_layout, channels); + if(!ch_layout.nb_channels) { + printf ("av_ch_layut_default failed! \n"); } int bitrate = asset->ac3_bitrate * 1000; av_init_packet(&avpkt); codec_context = avcodec_alloc_context3(codec); codec_context->bit_rate = bitrate; codec_context->sample_rate = sample_rate; - codec_context->channels = channels; - codec_context->channel_layout = layout; + codec_context->ch_layout.nb_channels = channels; + codec_context->ch_layout.u.mask = layout; + av_channel_layout_copy(&codec_context->ch_layout, &ch_layout); codec_context->sample_fmt = codec->sample_fmts[0]; - resample_context = swr_alloc_set_opts(NULL, - layout, codec_context->sample_fmt, sample_rate, - layout, AV_SAMPLE_FMT_S16, sample_rate, + SwrContext *tmp_resample_context = NULL; + int ret = swr_alloc_set_opts2(&tmp_resample_context, + &ch_layout, codec_context->sample_fmt, sample_rate, + &ch_layout, AV_SAMPLE_FMT_S16, sample_rate, 0, NULL); - swr_init(resample_context); + if(ret <0) printf("swr_alloc eror: %i \n", ret ); + if(tmp_resample_context){ + resample_context = tmp_resample_context; + if(swr_init(resample_context)) + { + eprintf(_("FileAC3::open_file failed to init swr.\n")); + result = 1; + } + } if(avcodec_open2(codec_context, codec, 0)) { eprintf(_("FileAC3::open_file failed to open codec.\n")); result = 1; } + av_channel_layout_uninit(&ch_layout); } } @@ -313,8 +329,9 @@ int FileAC3::write_samples(double **buffer, int64_t len) AVFrame *frame = av_frame_alloc(); frame->nb_samples = frame_size; frame->format = avctx->sample_fmt; - frame->channel_layout = avctx->channel_layout; + av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout); frame->sample_rate = avctx->sample_rate; + ret = av_frame_get_buffer(frame, 0); if( ret >= 0 ) { const uint8_t *samples = (uint8_t *)temp_raw + @@ -322,7 +339,7 @@ int FileAC3::write_samples(double **buffer, int64_t len) ret = swr_convert(resample_context, (uint8_t **)frame->extended_data, frame_size, &samples, frame_size); - } + } else { printf("fileAC3: av_frame_get_buffer failed!\n"); } if( ret >= 0 ) { frame->pts = avctx->sample_rate && avctx->time_base.num ? file->get_audio_position() : AV_NOPTS_VALUE ; @@ -341,39 +358,29 @@ int FileAC3::write_samples(double **buffer, int64_t len) } - - - - - AC3ConfigAudio::AC3ConfigAudio(BC_WindowBase *parent_window, Asset *asset) : BC_Window(_(PROGRAM_NAME ": Audio Compression"), parent_window->get_abs_cursor_x(1), parent_window->get_abs_cursor_y(1), - 500, - BC_OKButton::calculate_h() + 100, - 500, - BC_OKButton::calculate_h() + 100, - 0, - 0, - 1) + xS(500), BC_OKButton::calculate_h() + yS(100), + xS(500), BC_OKButton::calculate_h() + yS(100), + 0, 0, 1) { this->parent_window = parent_window; this->asset = asset; +// *** CONTEXT_HELP *** + context_help_set_keyword("Single File Rendering"); } void AC3ConfigAudio::create_objects() { - int x = 10, y = 10; - int x1 = 150; + int x = xS(10), y = yS(10); + int x1 = xS(150); lock_window("AC3ConfigAudio::create_objects"); add_tool(new BC_Title(x, y, _("Bitrate (kbps):"))); AC3ConfigAudioBitrate *bitrate; - add_tool(bitrate = - new AC3ConfigAudioBitrate(this, - x1, - y)); + add_tool(bitrate = new AC3ConfigAudioBitrate(this, x1, y)); bitrate->create_objects(); add_subwindow(new BC_OKButton(this)); @@ -388,16 +395,8 @@ int AC3ConfigAudio::close_event() } - - - - -AC3ConfigAudioBitrate::AC3ConfigAudioBitrate(AC3ConfigAudio *gui, - int x, - int y) - : BC_PopupMenu(x, - y, - 150, +AC3ConfigAudioBitrate::AC3ConfigAudioBitrate(AC3ConfigAudio *gui, int x, int y) + : BC_PopupMenu(x, y, xS(150), AC3ConfigAudioBitrate::bitrate_to_string(gui->string, gui->asset->ac3_bitrate)) { this->gui = gui; @@ -439,3 +438,4 @@ int AC3ConfigAudioBitrate::handle_event() } #endif +#endif //libzmpeg