Permalink
Browse files

Fixed a couple more ffmpeg _encode_* API deprecations

  • Loading branch information...
1 parent 0fe08f2 commit 449d36dec79bd97cebd4fee3e19ab7224689ecc5 @Beirdo Beirdo committed Apr 12, 2012
View
2 mythtv/external/FFmpeg/libavcodec/golomb.h
@@ -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);
View
28 mythtv/libs/libmyth/audio/audiooutputdigitalencoder.cpp
@@ -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;
@@ -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 +
@@ -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;
@@ -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;
}
View
13 mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
@@ -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");
View
1 mythtv/libs/libmythtv/nuppeldecoder.cpp
@@ -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;

0 comments on commit 449d36d

Please sign in to comment.