Skip to content

Commit

Permalink
FFmpegWriter: Replace AVRational casts with av_make_q()
Browse files Browse the repository at this point in the history
Some compilers balk at the compound initializers in the cast form
  • Loading branch information
ferdnyc committed Mar 22, 2020
1 parent 527acfe commit f9a91a5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/FFmpegWriter.cpp
Expand Up @@ -811,7 +811,7 @@ void FFmpegWriter::flush_encoders() {
for (;;) {

// Increment PTS (in frames and scaled to the codec's timebase)
write_video_count += av_rescale_q(1, (AVRational) {info.fps.den, info.fps.num}, video_codec_ctx->time_base);
write_video_count += av_rescale_q(1, av_make_q(info.fps.den, info.fps.num), video_codec_ctx->time_base);

AVPacket pkt;
av_init_packet(&pkt);
Expand Down Expand Up @@ -915,7 +915,7 @@ void FFmpegWriter::flush_encoders() {
// for some reason, it requires me to multiply channels X 2
write_audio_count += av_rescale_q(audio_input_position / (audio_codec_ctx->channels * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)), av_make_q(1, info.sample_rate), audio_codec_ctx->time_base);
#else
write_audio_count += av_rescale_q(audio_input_position / audio_codec_ctx->channels, (AVRational){1, info.sample_rate}, audio_codec_ctx->time_base);
write_audio_count += av_rescale_q(audio_input_position / audio_codec_ctx->channels, av_make_q(1, info.sample_rate), audio_codec_ctx->time_base);
#endif

AVPacket pkt;
Expand Down Expand Up @@ -1964,7 +1964,7 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame *fra
pkt.size = sizeof(AVPicture);

// Increment PTS (in frames and scaled to the codec's timebase)
write_video_count += av_rescale_q(1, (AVRational) {info.fps.den, info.fps.num}, video_codec_ctx->time_base);
write_video_count += av_rescale_q(1, av_make_q(info.fps.den, info.fps.num), video_codec_ctx->time_base);
pkt.pts = write_video_count;

/* write the compressed frame in the media file */
Expand All @@ -1991,7 +1991,7 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame *fra
uint8_t *video_outbuf = NULL;

// Increment PTS (in frames and scaled to the codec's timebase)
write_video_count += av_rescale_q(1, (AVRational) {info.fps.den, info.fps.num}, video_codec_ctx->time_base);
write_video_count += av_rescale_q(1, av_make_q(info.fps.den, info.fps.num), video_codec_ctx->time_base);

// Assign the initial AVFrame PTS from the frame counter
frame_final->pts = write_video_count;
Expand Down

0 comments on commit f9a91a5

Please sign in to comment.