diff --git a/mythtv/libs/libmyth/audio/audiooutputdigitalencoder.cpp b/mythtv/libs/libmyth/audio/audiooutputdigitalencoder.cpp
index e902732..bd6dbcd 100644
a
|
b
|
size_t AudioOutputDigitalEncoder::Encode(void *buf, int len, AudioFormat format) |
239 | 239 | av_init_packet(&pkt); |
240 | 240 | pkt.data = NULL; |
241 | 241 | pkt.size = 0; |
242 | | int got_packet = 0; |
| 242 | bool got_packet = false; |
243 | 243 | |
244 | 244 | AudioOutputUtil::DeinterleaveSamples( |
245 | 245 | FORMAT_S16, channels, |
… |
… |
size_t AudioOutputDigitalEncoder::Encode(void *buf, int len, AudioFormat format) |
247 | 247 | (uint8_t*)(in + i * samples_per_frame), |
248 | 248 | size_channel * channels); |
249 | 249 | |
250 | | int ret = avcodec_encode_audio2(av_context, &pkt, m_frame, |
251 | | &got_packet); |
| 250 | // SUGGESTION |
| 251 | // Now that avcodec_encode_audio2 is deprecated and replaced |
| 252 | // by 2 calls, this could be optimized |
| 253 | // into separate routines or separate threads. |
| 254 | int ret = avcodec_receive_packet(av_context, &pkt); |
| 255 | if (ret == 0) |
| 256 | got_packet = true; |
| 257 | if (ret == AVERROR(EAGAIN)) |
| 258 | ret = 0; |
| 259 | if (ret == 0) |
| 260 | ret = avcodec_send_frame(av_context, m_frame); |
| 261 | // if ret from avcodec_send_frame is AVERROR(EAGAIN) then |
| 262 | // there are 2 packets to be received while only 1 frame to be |
| 263 | // sent. The code does not cater for this. Hopefully it will not happen. |
252 | 264 | |
253 | 265 | if (ret < 0) |
254 | 266 | { |
255 | | LOG(VB_AUDIO, LOG_ERR, LOC + "AC-3 encode error"); |
| 267 | char error[AV_ERROR_MAX_STRING_SIZE]; |
| 268 | LOG(VB_GENERAL, LOG_ERR, LOC + |
| 269 | QString("audio encode error: %1 (%2)") |
| 270 | .arg(av_make_error_string(error, sizeof(error), ret)) |
| 271 | .arg(got_packet)); |
256 | 272 | return ret; |
257 | 273 | } |
258 | 274 | i++; |
diff --git a/mythtv/libs/libmythtv/avformatwriter.cpp b/mythtv/libs/libmythtv/avformatwriter.cpp
index e34dc2d..a3282be 100644
a
|
b
|
int AVFormatWriter::WriteAudioFrame(unsigned char *buf, int /*fnum*/, long long |
323 | 323 | bswap_16_buf((short int*) buf, m_audioFrameSize, m_audioChannels); |
324 | 324 | #endif |
325 | 325 | |
326 | | int got_packet = 0; |
| 326 | bool got_packet = false; |
327 | 327 | int ret = 0; |
328 | 328 | int samples_per_avframe = m_audioFrameSize * m_audioChannels; |
329 | 329 | int sampleSizeIn = AudioOutputSettings::SampleSize(FORMAT_S16); |
… |
… |
int AVFormatWriter::WriteAudioFrame(unsigned char *buf, int /*fnum*/, long long |
370 | 370 | |
371 | 371 | { |
372 | 372 | QMutexLocker locker(avcodeclock); |
373 | | ret = avcodec_encode_audio2(m_audioStream->codec, &pkt, |
374 | | m_audPicture, &got_packet); |
| 373 | // SUGGESTION |
| 374 | // Now that avcodec_encode_audio2 is deprecated and replaced |
| 375 | // by 2 calls, this could be optimized |
| 376 | // into separate routines or separate threads. |
| 377 | got_packet = false; |
| 378 | ret = avcodec_receive_packet(m_audioStream->codec, &pkt); |
| 379 | if (ret == 0) |
| 380 | got_packet = true; |
| 381 | if (ret == AVERROR(EAGAIN)) |
| 382 | ret = 0; |
| 383 | if (ret == 0) |
| 384 | ret = avcodec_send_frame(m_audioStream->codec, m_audPicture); |
| 385 | // if ret from avcodec_send_frame is AVERROR(EAGAIN) then |
| 386 | // there are 2 packets to be received while only 1 frame to be |
| 387 | // sent. The code does not cater for this. Hopefully it will not happen. |
375 | 388 | } |
376 | 389 | |
377 | 390 | if (ret < 0) |
378 | 391 | { |
379 | | LOG(VB_RECORD, LOG_ERR, "avcodec_encode_audio2() failed"); |
| 392 | char error[AV_ERROR_MAX_STRING_SIZE]; |
| 393 | LOG(VB_GENERAL, LOG_ERR, LOC + |
| 394 | QString("audio encode error: %1 (%2)") |
| 395 | .arg(av_make_error_string(error, sizeof(error), ret)) |
| 396 | .arg(got_packet)); |
380 | 397 | return ret; |
381 | 398 | } |
382 | 399 | |
diff --git a/mythtv/programs/mythtranscode/external/replex/replex.c b/mythtv/programs/mythtranscode/external/replex/replex.c
index d94af07..f5821f7 100644
a
|
b
|
static int avcodec_encode_audio(AVCodecContext *avctx, |
88 | 88 | { |
89 | 89 | AVPacket pkt; |
90 | 90 | AVFrame *frame; |
91 | | int ret, samples_size, got_packet; |
| 91 | int ret, samples_size; |
92 | 92 | |
93 | 93 | av_init_packet(&pkt); |
94 | 94 | pkt.data = buf; |
… |
… |
static int avcodec_encode_audio(AVCodecContext *avctx, |
139 | 139 | frame = NULL; |
140 | 140 | } |
141 | 141 | |
142 | | got_packet = 0; |
143 | | ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet); |
| 142 | // SUGGESTION |
| 143 | // Now that avcodec_encode_audio2 is deprecated and replaced |
| 144 | // by 2 calls, this could be optimized |
| 145 | // into separate routines or separate threads. |
| 146 | ret = avcodec_receive_packet(avctx, &pkt); |
| 147 | if (ret != 0) |
| 148 | pkt.size=0; |
| 149 | if (ret == AVERROR(EAGAIN)) |
| 150 | ret = 0; |
| 151 | if (ret == 0) |
| 152 | ret = avcodec_send_frame(avctx, frame); |
| 153 | |
| 154 | if (ret < 0) |
| 155 | { |
| 156 | char error[AV_ERROR_MAX_STRING_SIZE+25]; |
| 157 | strcpy(error,"audio encode error: "); |
| 158 | strcat(error, av_make_error_string(error, sizeof(error), ret)); |
| 159 | LOG(VB_GENERAL, LOG_ERR, error); |
| 160 | } |
144 | 161 | |
145 | 162 | /* free any side data since we cannot return it */ |
146 | 163 | av_packet_free_side_data(&pkt); |