examples/hw_decode: Don't use stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
86ec1093eb
commit
e9182820ad
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
|
|||||||
AVStream *video = NULL;
|
AVStream *video = NULL;
|
||||||
AVCodecContext *decoder_ctx = NULL;
|
AVCodecContext *decoder_ctx = NULL;
|
||||||
const AVCodec *decoder = NULL;
|
const AVCodec *decoder = NULL;
|
||||||
AVPacket packet;
|
AVPacket *packet = NULL;
|
||||||
enum AVHWDeviceType type;
|
enum AVHWDeviceType type;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -172,6 +172,12 @@ int main(int argc, char *argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packet = av_packet_alloc();
|
||||||
|
if (!packet) {
|
||||||
|
fprintf(stderr, "Failed to allocate AVPacket\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* open the input file */
|
/* open the input file */
|
||||||
if (avformat_open_input(&input_ctx, argv[2], NULL, NULL) != 0) {
|
if (avformat_open_input(&input_ctx, argv[2], NULL, NULL) != 0) {
|
||||||
fprintf(stderr, "Cannot open input file '%s'\n", argv[2]);
|
fprintf(stderr, "Cannot open input file '%s'\n", argv[2]);
|
||||||
@ -227,23 +233,21 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* actual decoding and dump the raw data */
|
/* actual decoding and dump the raw data */
|
||||||
while (ret >= 0) {
|
while (ret >= 0) {
|
||||||
if ((ret = av_read_frame(input_ctx, &packet)) < 0)
|
if ((ret = av_read_frame(input_ctx, packet)) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (video_stream == packet.stream_index)
|
if (video_stream == packet->stream_index)
|
||||||
ret = decode_write(decoder_ctx, &packet);
|
ret = decode_write(decoder_ctx, packet);
|
||||||
|
|
||||||
av_packet_unref(&packet);
|
av_packet_unref(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* flush the decoder */
|
/* flush the decoder */
|
||||||
packet.data = NULL;
|
ret = decode_write(decoder_ctx, NULL);
|
||||||
packet.size = 0;
|
|
||||||
ret = decode_write(decoder_ctx, &packet);
|
|
||||||
av_packet_unref(&packet);
|
|
||||||
|
|
||||||
if (output_file)
|
if (output_file)
|
||||||
fclose(output_file);
|
fclose(output_file);
|
||||||
|
av_packet_free(&packet);
|
||||||
avcodec_free_context(&decoder_ctx);
|
avcodec_free_context(&decoder_ctx);
|
||||||
avformat_close_input(&input_ctx);
|
avformat_close_input(&input_ctx);
|
||||||
av_buffer_unref(&hw_device_ctx);
|
av_buffer_unref(&hw_device_ctx);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user