Log in

View Full Version : [Help Needed] On FFMPEG & Co


jpsdr
28th March 2019, 20:35
Yes i know, again...:D
I don't know where to ask, so i'm trying here, as it's related to x264, hoping some people with libav/ffmpeg knowledge will take a look here.

Finaly i've decided to try to implement all t_mod patches, begining with the first one, the bigest and hardest: audio support !

It was a little long, but less hard than expected.
Nevertheless, in the end, because of ffmpeg update, there was 4 unknow things, one label and 3 functions.
The label, there was another label of the same name with just AV_ at the begining of it. I assume i just had to rename with this.
According my results on net research, on 2 of the 3 functions, it seems it was just a simple renaming.

The last one was trickier. The function has a replacement, but parameters were different. The function not supported anymore was avcodec_decode_audio3, replaced by avcodec_decode_audio4. This last one is now deprecated, but i'll save it for later.
I've found on the net the code of a function emulating avcodec_decode_audio3 using avcodec_decode_audio4:

static int decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt)
{
AVFrame frame = { { 0 } };
int ret, got_frame = 0;

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) return -1;

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;
}

My issue is that i have absolutely no knowledge on ffmpeg/libav and all this stuff.
So, i don't know if this is working properly or not. x264 is building, doesn't mean it's working...;)
It's building, but there is a lot of warning with deprecated functions, it will probably not live long on ffmpeg update (but a least, for now...).

So, i need the help on updating the deprecated functions on the new actual recommended version. Unfortunately, the replacement functions haven't the same parameters as the old ones, and i absolutely don't know how to use them and replace the deprecated.
There is two way of updating: The "proper" way, which may need a big rewrite of several parts. The "less nice" way, doing the same thing i've done for avcodec_decode_audio3: emulate the old function, using the new one inside. Doing this may be easier and quicker.
If there is someone who can help, take a look, make build, looking the warning to see the deprecated functions, etc..., i've begin to put thing on my github here (https://github.com/jpsdr/x264/tree/t_mod_New).

:thanks: