Author Topic: Compiling latest Valdec with *static* libavcodec  (Read 12841 times)

LoRd_MuldeR

  • Active user
  • ***
  • Posts: 26
    • View Profile
    • MuldeR's OpenSource Stuff
Re: Compiling latest Valdec with *static* libavcodec
« Reply #30 on: March 10, 2013, 09:32:59 PM »
Seems like they have fixed libav, so "our" configuration will now compile through fine without any workarounds.

For what it's worth, here is a new libav build:
http://www.mediafire.com/file/j2p7dihi5aufau9/libav-dev.Win32-MSVC-Static.2013-03-10.7z

[EDIT] The bad news is that avcodec_decode_audio3() has been removed and we need to update to avcodec_decode_audio4() :undecided: [/EDIT]
« Last Edit: March 10, 2013, 10:44:07 PM by LoRd_MuldeR »

valex

  • Administrator
  • Active user
  • *****
  • Posts: 598
    • View Profile
Re: Compiling latest Valdec with *static* libavcodec
« Reply #31 on: March 11, 2013, 12:06:22 PM »
Let me summarize the features proposed:
* Latest FFMPEG, static and shared linking. (done)
* Use static linking for valdec. (done)
* UTF-8 support at AutoFile. (done)
* UTF-8 support at command line arguments (working on).
* Error reporting to stderr.
* stdin/stdout i/o.
(did I forget something?)

FFMPEG 1.1.3 was used, build instruction.
Latest versions: valib, tools

LoRd_MuldeR

  • Active user
  • ***
  • Posts: 26
    • View Profile
    • MuldeR's OpenSource Stuff
Re: Compiling latest Valdec with *static* libavcodec
« Reply #32 on: March 11, 2013, 01:57:26 PM »
Yeah looks good to me. Great work :)

Though it seems you patched an older ffmpeg release rather than using the up-to-date ffmpeg/libav, which has fixed the earlier compilation issue. Is that because they have removed the avcodec_decode_audio3() API in favor of avcodec_decode_audio4()? If so, I would suggest porting valdec to work with the new API, or we will be bound to outdated ffmpeg/libav. Using the current API, would definitely make Valdec more future-proof. I think this function could help. It originally came from "libavcodec/utils.cpp" and was used to emulate the old API, before it was removed altogether...

Code: [Select]
int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
                                              int *frame_size_ptr,
                                              AVPacket *avpkt)
{
    AVFrame frame = { { 0 } };
    int ret, got_frame = 0;

    if (avctx->get_buffer != avcodec_default_get_buffer) {
        av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with"
                                    "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n");
        av_log(avctx, AV_LOG_ERROR, "Please port your application to "
                                    "avcodec_decode_audio4()\n");
        avctx->get_buffer = avcodec_default_get_buffer;
    }

    ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt);

    if (ret >= 0 && got_frame) {
        int ch, plane_size;
        int planar    = av_sample_fmt_is_planar(avctx->sample_fmt);
        int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels,
                                                   frame.nb_samples,
                                                   avctx->sample_fmt, 1);
        if (*frame_size_ptr < data_size) {
            av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for "
                                        "the current frame (%d < %d)\n", *frame_size_ptr, data_size);
            return AVERROR(EINVAL);
        }

        memcpy(samples, frame.extended_data[0], plane_size);

        if (planar && avctx->channels > 1) {
            uint8_t *out = ((uint8_t *)samples) + plane_size;
            for (ch = 1; ch < avctx->channels; ch++) {
                memcpy(out, frame.extended_data[ch], plane_size);
                out += plane_size;
            }
        }
        *frame_size_ptr = data_size;
    } else {
        *frame_size_ptr = 0;
    }
    return ret;
}

Also: I wonder what exactly is still missing to get "UTF-8 support at command line arguments" working, because that is a very important point for me.

Regards,
MuldeR


(BTW: In your post you refer to "FFMPEG 1.1.3", but your Wiki article is about "FFMPEG 1.1.2")
« Last Edit: March 11, 2013, 02:21:31 PM by LoRd_MuldeR »

LoRd_MuldeR

  • Active user
  • ***
  • Posts: 26
    • View Profile
    • MuldeR's OpenSource Stuff
Re: Compiling latest Valdec with *static* libavcodec
« Reply #33 on: March 16, 2013, 06:03:08 PM »
Hi.

Today I hacked in UTF-8 support for the CLI args too into your latest version.

Please have a look at:
http://pastie.org/private/egstk6uiah99kks06gpkra

Note: This code won't compile on non-Windows platforms, but that should be very easy to fix by adding an #ifdef around the CLI initialization.

Also, can you please include the Flush fix into your official code? I think other people might need that too.
« Last Edit: March 16, 2013, 09:11:13 PM by LoRd_MuldeR »

valex

  • Administrator
  • Active user
  • *****
  • Posts: 598
    • View Profile
Re: Compiling latest Valdec with *static* libavcodec
« Reply #34 on: April 06, 2013, 01:17:59 PM »
First of all, thanks for your help!

New tools release with unicode support:
http://ac3filter.net/wiki/AC3Filter_tools_1.0a

Unicode usage notes:
http://ac3filter.net/wiki/AC3Filter_tools#Command-line_parameters_in_Unicode

> Also, can you please include the Flush fix into your official code? I think other people might need that too.
Stderr output and fflush() included into the new working version at repository.

> BTW: In your post you refer to "FFMPEG 1.1.3", but your Wiki article is about "FFMPEG 1.1.2"
ffmpeg patch works with 1.1.2 - 1.1.4 (already updated) versions.

LoRd_MuldeR

  • Active user
  • ***
  • Posts: 26
    • View Profile
    • MuldeR's OpenSource Stuff
Re: Compiling latest Valdec with *static* libavcodec
« Reply #35 on: April 06, 2013, 09:21:10 PM »
Thank you for the new version :good:

LoRd_MuldeR

  • Active user
  • ***
  • Posts: 26
    • View Profile
    • MuldeR's OpenSource Stuff
Re: Compiling latest Valdec with *static* libavcodec
« Reply #36 on: April 07, 2013, 10:15:54 PM »
STDOUT/SDIN support plus Flush-Fix for the AC3Filter tools 1.0a release:
http://pastie.org/private/ptgsacybhvdju2dmvka2ua

(I still hacked this into AutoFile because I think this is easier than doing it separately for each tool)
« Last Edit: April 07, 2013, 10:33:58 PM by LoRd_MuldeR »