examples/filtering_audio: Don't use stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
f495604361
commit
a75f518b65
@ -215,12 +215,12 @@ static void print_frame(const AVFrame *frame)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
AVPacket packet;
|
AVPacket *packet = av_packet_alloc();
|
||||||
AVFrame *frame = av_frame_alloc();
|
AVFrame *frame = av_frame_alloc();
|
||||||
AVFrame *filt_frame = av_frame_alloc();
|
AVFrame *filt_frame = av_frame_alloc();
|
||||||
|
|
||||||
if (!frame || !filt_frame) {
|
if (!packet || !frame || !filt_frame) {
|
||||||
perror("Could not allocate frame");
|
fprintf(stderr, "Could not allocate frame or packet\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
@ -235,11 +235,11 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* read all packets */
|
/* read all packets */
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
if ((ret = av_read_frame(fmt_ctx, packet)) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (packet.stream_index == audio_stream_index) {
|
if (packet->stream_index == audio_stream_index) {
|
||||||
ret = avcodec_send_packet(dec_ctx, &packet);
|
ret = avcodec_send_packet(dec_ctx, packet);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");
|
av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");
|
||||||
break;
|
break;
|
||||||
@ -275,12 +275,13 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
av_packet_unref(&packet);
|
av_packet_unref(packet);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
avfilter_graph_free(&filter_graph);
|
avfilter_graph_free(&filter_graph);
|
||||||
avcodec_free_context(&dec_ctx);
|
avcodec_free_context(&dec_ctx);
|
||||||
avformat_close_input(&fmt_ctx);
|
avformat_close_input(&fmt_ctx);
|
||||||
|
av_packet_free(&packet);
|
||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
av_frame_free(&filt_frame);
|
av_frame_free(&filt_frame);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user