mirror of https://git.ffmpeg.org/ffmpeg.git
avisynth: Use av_packet_from_data instead of av_new_packet
If the audio changes from 9eac7c4
were merged as they were, this
would cause scripts with both video+audio to fail with a lot of
audio decoding errors (the video would be fine). Scripts with
only one of either video or audio were unaffected. Additionally,
the av_packet changes in general caused seeking to break.
Using av_packet_from_data allows video+audio scripts to work as
expected, without audio decoding errors. It also fixes seeking.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
02dd178d9d
commit
16ae337bd8
|
@ -421,7 +421,7 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt,
|
|||
AVS_VideoFrame *frame;
|
||||
unsigned char *dst_p;
|
||||
const unsigned char *src_p;
|
||||
int n, i, plane, rowsize, planeheight, pitch, bits;
|
||||
int n, i, plane, rowsize, planeheight, pitch, bits, ret;
|
||||
const char *error;
|
||||
|
||||
if (avs->curr_frame >= avs->vi->num_frames)
|
||||
|
@ -460,9 +460,15 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt,
|
|||
if (!pkt->size)
|
||||
return AVERROR_UNKNOWN;
|
||||
|
||||
if (av_new_packet(pkt, pkt->size) < 0)
|
||||
pkt->data = av_malloc(pkt->size);
|
||||
if (!pkt->data)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
if ((ret = av_packet_from_data(pkt, pkt->data, pkt->size)) < 0) {
|
||||
av_packet_unref(pkt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
frame = avs_library.avs_get_frame(avs->clip, n);
|
||||
error = avs_library.avs_clip_get_error(avs->clip);
|
||||
if (error) {
|
||||
|
@ -511,7 +517,7 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt,
|
|||
{
|
||||
AviSynthContext *avs = s->priv_data;
|
||||
AVRational fps, samplerate;
|
||||
int samples;
|
||||
int samples, ret;
|
||||
int64_t n;
|
||||
const char *error;
|
||||
|
||||
|
@ -558,9 +564,15 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt,
|
|||
if (!pkt->size)
|
||||
return AVERROR_UNKNOWN;
|
||||
|
||||
if (av_new_packet(pkt, pkt->size) < 0)
|
||||
pkt->data = av_malloc(pkt->size);
|
||||
if (!pkt->data)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
if ((ret = av_packet_from_data(pkt, pkt->data, pkt->size)) < 0) {
|
||||
av_packet_unref(pkt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
avs_library.avs_get_audio(avs->clip, pkt->data, n, samples);
|
||||
error = avs_library.avs_clip_get_error(avs->clip);
|
||||
if (error) {
|
||||
|
|
Loading…
Reference in New Issue