|
|
@ -35,6 +35,10 @@ extern "C" { |
|
|
|
/* Global timestamp for the audio frames. */ |
|
|
|
/* Global timestamp for the audio frames. */ |
|
|
|
static int64_t pts = 0; |
|
|
|
static int64_t pts = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static AVPacket input_packet; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static AVPacket output_packet; |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Open an input file and the required decoder. |
|
|
|
* Open an input file and the required decoder. |
|
|
|
* |
|
|
|
* |
|
|
@ -201,16 +205,6 @@ cleanup: |
|
|
|
return error < 0 ? error : AVERROR_EXIT; |
|
|
|
return error < 0 ? error : AVERROR_EXIT; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Initialize one data packet for reading or writing. |
|
|
|
|
|
|
|
* @param packet Packet to be initialized |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
static void init_packet(AVPacket *packet) { |
|
|
|
|
|
|
|
av_init_packet(packet); |
|
|
|
|
|
|
|
packet->data = nullptr; |
|
|
|
|
|
|
|
packet->size = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Initialize one audio frame for reading from the input file. |
|
|
|
* Initialize one audio frame for reading from the input file. |
|
|
|
* |
|
|
|
* |
|
|
@ -288,8 +282,6 @@ static int decode_audio_frame(AVFrame *frame, |
|
|
|
AVCodecContext *input_codec_context, |
|
|
|
AVCodecContext *input_codec_context, |
|
|
|
int *data_present, int *finished) { |
|
|
|
int *data_present, int *finished) { |
|
|
|
int error; |
|
|
|
int error; |
|
|
|
AVPacket input_packet; |
|
|
|
|
|
|
|
init_packet(&input_packet); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((error = av_read_frame(input_format_context, &input_packet)) < 0) { |
|
|
|
if ((error = av_read_frame(input_format_context, &input_packet)) < 0) { |
|
|
|
if (error == AVERROR_EOF) |
|
|
|
if (error == AVERROR_EOF) |
|
|
@ -496,8 +488,6 @@ static int encode_audio_frame(AVFrame *frame, |
|
|
|
AVCodecContext *output_codec_context, |
|
|
|
AVCodecContext *output_codec_context, |
|
|
|
int *data_present) { |
|
|
|
int *data_present) { |
|
|
|
int error; |
|
|
|
int error; |
|
|
|
AVPacket output_packet; |
|
|
|
|
|
|
|
init_packet(&output_packet); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set a timestamp based on the sample rate for the container. */ |
|
|
|
/* Set a timestamp based on the sample rate for the container. */ |
|
|
|
if (frame) { |
|
|
|
if (frame) { |
|
|
|