Skip to content

Commit

Permalink
fix compile errors with ffmpeg git
Browse files Browse the repository at this point in the history
The FF_MIN_BUFFER_SIZE macro was renamed to AV_INPUT_BUFFER_MIN_SIZE at
some point, so check for the newer variant first.

The AVFMT_RAWPICTURE macro seems to be gone, but affected code was an
edge-case so compile it out if the macro is not present.
  • Loading branch information
rkitover committed Mar 19, 2018
1 parent 5ae853a commit f3f6ee7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/common/ffmpeg.cpp
Expand Up @@ -86,11 +86,22 @@ static void avformat_free_context(AVFormatContext *ctx)
// I have no idea what size to make these buffers
// I don't see any ffmpeg functions to guess the size, either

// use frame size, or FF_MIN_BUFFER_SIZE (that seems to be what it wants)
#ifdef AV_INPUT_BUFFER_MIN_SIZE

// use frame size, or AV_INPUT_BUFFER_MIN_SIZE (that seems to be what it wants)
#define AUDIO_BUF_LEN (frame_len > AV_INPUT_BUFFER_MIN_SIZE ? frame_len : AV_INPUT_BUFFER_MIN_SIZE)
// use maximum frame size * 32 bpp * 2 for good measure
#define VIDEO_BUF_LEN (AV_INPUT_BUFFER_MIN_SIZE + 256 * 244 * 4 * 2)

#else

// use frame size, or FF_MIN_BUFFER_SIZE (that seems to be what it wants)
#define AUDIO_BUF_LEN (frame_len > FF_MIN_BUFFER_SIZE ? frame_len : FF_MIN_BUFFER_SIZE)
// use maximum frame size * 32 bpp * 2 for good measure
// use maximum frame size * 32 bpp * 2 for good measure
#define VIDEO_BUF_LEN (FF_MIN_BUFFER_SIZE + 256 * 244 * 4 * 2)

#endif

bool MediaRecorder::did_init = false;

MediaRecorder::MediaRecorder() : oc(0), vid_st(0), aud_st(0), video_buf(0),
Expand Down Expand Up @@ -443,13 +454,15 @@ MediaRet MediaRecorder::AddFrame(const uint8_t *vid)
}
av_init_packet(&pkt);
pkt.stream_index = vid_st->index;
#ifdef AVFMT_RAWPICTURE
if(oc->oformat->flags & AVFMT_RAWPICTURE) {
// this won't work due to border
// not sure what formats set this, anyway
pkt.flags |= AV_PKT_FLAG_KEY;
pkt.data = f->data[0];
pkt.size = linesize * ctx->height;
} else {
#endif
#if LIBAVCODEC_VERSION_MAJOR >= 56
pkt.data = video_buf;
pkt.size = VIDEO_BUF_LEN;
Expand All @@ -476,7 +489,9 @@ MediaRet MediaRecorder::AddFrame(const uint8_t *vid)
if(ctx->coded_frame->key_frame)
pkt.flags |= AV_PKT_FLAG_KEY;
pkt.data = video_buf;
#ifdef AVFMT_RAWPICTURE
}
#endif
if(av_interleaved_write_frame(oc, &pkt) < 0) {
avformat_free_context(oc);
oc = NULL;
Expand Down

0 comments on commit f3f6ee7

Please sign in to comment.