Skip to content

Commit

Permalink
Fixed a couple more ffmpeg _encode_* API deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
Beirdo committed Apr 12, 2012
1 parent 0fe08f2 commit 449d36d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mythtv/external/FFmpeg/libavcodec/golomb.h
Expand Up @@ -302,7 +302,7 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int
}else{
int i;
for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) {
if (gb->size_in_bits <= re_index)
if (gb->size_in_bits <= (int)re_index)
return -1;
LAST_SKIP_BITS(re, gb, 1);
UPDATE_CACHE(re, gb);
Expand Down
28 changes: 20 additions & 8 deletions mythtv/libs/libmyth/audio/audiooutputdigitalencoder.cpp
Expand Up @@ -110,7 +110,7 @@ bool AudioOutputDigitalEncoder::Init(
return false;
}

av_context = avcodec_alloc_context();
av_context = avcodec_alloc_context3(codec);
avcodec_get_context_defaults3(av_context, codec);

av_context->bit_rate = bitrate;
Expand All @@ -125,7 +125,7 @@ bool AudioOutputDigitalEncoder::Init(
#endif

// open it
ret = avcodec_open(av_context, codec);
ret = avcodec_open2(av_context, codec, NULL);
if (ret < 0)
{
LOG(VB_GENERAL, LOG_ERR, LOC +
Expand Down Expand Up @@ -195,15 +195,25 @@ size_t AudioOutputDigitalEncoder::Encode(void *buf, int len, AudioFormat format)
int frames = inlen / sizeof(inbuf_t) / samples_per_frame;
int i = 0;

AVFrame *frame = avcodec_alloc_frame();

while (i < frames)
{
int outsize = avcodec_encode_audio(
av_context,
(uint8_t *)m_encodebuffer,
sizeof(m_encodebuffer),
(short *)(in + i * samples_per_frame));
AVPacket packet;
packet.data = (uint8_t *)m_encodebuffer;
packet.size = sizeof(m_encodebuffer);

frame->data[0] = (uint8_t *)&in[i * samples_per_frame];
frame->linesize[0] = inlen;
frame->nb_samples = frames - i;
frame->format = AV_SAMPLE_FMT_S16;

int got_packet = 0;

if (outsize < 0)
int outsize = avcodec_encode_audio2(av_context, &packet, frame,
&got_packet);

if (outsize < 0 || !got_packet)
{
LOG(VB_AUDIO, LOG_ERR, LOC + "AC-3 encode error");
return outlen;
Expand Down Expand Up @@ -243,6 +253,8 @@ size_t AudioOutputDigitalEncoder::Encode(void *buf, int len, AudioFormat format)
i++;
}

av_free(frame);

memmove(in, in + i * samples_per_frame, inlen);
return outlen;
}
Expand Down
13 changes: 10 additions & 3 deletions mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
Expand Up @@ -2956,10 +2956,17 @@ void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync,

if (!hardware_encode)
{
AVPacket packet;
packet.data = (uint8_t *)strm;
packet.size = len;

int got_packet = 0;

QMutexLocker locker(avcodeclock);
tmp = avcodec_encode_video(mpa_vidctx, (unsigned char *)strm,
len, &mpa_picture);
if (tmp == -1)
tmp = avcodec_encode_video2(mpa_vidctx, &packet, &mpa_picture,
&got_packet);

if (tmp < 0 || !got_packet)
{
LOG(VB_GENERAL, LOG_ERR, LOC +
"WriteVideo : avcodec_encode_video() failed");
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/nuppeldecoder.cpp
Expand Up @@ -1054,7 +1054,6 @@ bool NuppelDecoder::GetFrame(DecodeType decodetype)
bool ret = false;
int seeklen = 0;
AVPacket pkt;
AVFrame *frame = avcodec_alloc_frame();

decoded_video_frame = NULL;

Expand Down

0 comments on commit 449d36d

Please sign in to comment.