equal
deleted
inserted
replaced
64 #endif |
64 #endif |
65 |
65 |
66 #if LIBAVCODEC_VERSION_MAJOR < 56 |
66 #if LIBAVCODEC_VERSION_MAJOR < 56 |
67 #define av_frame_alloc avcodec_alloc_frame |
67 #define av_frame_alloc avcodec_alloc_frame |
68 #define av_frame_free av_freep |
68 #define av_frame_free av_freep |
|
69 #define av_packet_rescale_ts rescale_ts |
|
70 |
|
71 static void rescale_ts(AVPacket *pkt, AVRational ctb, AVRational stb) |
|
72 { |
|
73 if (pkt->pts != AV_NOPTS_VALUE) |
|
74 pkt->pts = av_rescale_q(pkt->pts, ctb, stb); |
|
75 if (pkt->dts != AV_NOPTS_VALUE) |
|
76 pkt->dts = av_rescale_q(pkt->dts, ctb, stb); |
|
77 if (pkt->duration > 0) |
|
78 pkt->duration = av_rescale_q(pkt->duration, ctb, stb); |
|
79 } |
69 #endif |
80 #endif |
70 |
81 |
71 #if LIBAVCODEC_VERSION_MAJOR < 57 |
82 #if LIBAVCODEC_VERSION_MAJOR < 57 |
72 #define AV_CODEC_CAP_DELAY CODEC_CAP_DELAY |
83 #define AV_CODEC_CAP_DELAY CODEC_CAP_DELAY |
73 #define AV_CODEC_CAP_VARIABLE_FRAME_SIZE CODEC_CAP_VARIABLE_FRAME_SIZE |
84 #define AV_CODEC_CAP_VARIABLE_FRAME_SIZE CODEC_CAP_VARIABLE_FRAME_SIZE |
214 int got_packet; |
225 int got_packet; |
215 if (avcodec_encode_audio2(g_pAudio, &Packet, pFrame, &got_packet) != 0) |
226 if (avcodec_encode_audio2(g_pAudio, &Packet, pFrame, &got_packet) != 0) |
216 return FatalError("avcodec_encode_audio2 failed"); |
227 return FatalError("avcodec_encode_audio2 failed"); |
217 if (!got_packet) |
228 if (!got_packet) |
218 return 0; |
229 return 0; |
|
230 |
|
231 av_packet_rescale_ts(&Packet, g_pAudio->time_base, g_pAStream->time_base); |
219 #else |
232 #else |
220 if (NumSamples == 0) |
233 if (NumSamples == 0) |
221 return 0; |
234 return 0; |
222 int BufferSize = OUTBUFFER_SIZE; |
235 int BufferSize = OUTBUFFER_SIZE; |
223 if (g_pAudio->frame_size == 0) |
236 if (g_pAudio->frame_size == 0) |
378 if (avcodec_encode_video2(g_pVideo, &Packet, pFrame, &got_packet) < 0) |
391 if (avcodec_encode_video2(g_pVideo, &Packet, pFrame, &got_packet) < 0) |
379 return FatalError("avcodec_encode_video2 failed"); |
392 return FatalError("avcodec_encode_video2 failed"); |
380 if (!got_packet) |
393 if (!got_packet) |
381 return 0; |
394 return 0; |
382 |
395 |
383 if (Packet.pts != AV_NOPTS_VALUE) |
396 av_packet_rescale_ts(&Packet, g_pVideo->time_base, g_pVStream->time_base); |
384 Packet.pts = av_rescale_q(Packet.pts, g_pVideo->time_base, g_pVStream->time_base); |
|
385 if (Packet.dts != AV_NOPTS_VALUE) |
|
386 Packet.dts = av_rescale_q(Packet.dts, g_pVideo->time_base, g_pVStream->time_base); |
|
387 #else |
397 #else |
388 Packet.size = avcodec_encode_video(g_pVideo, g_OutBuffer, OUTBUFFER_SIZE, pFrame); |
398 Packet.size = avcodec_encode_video(g_pVideo, g_OutBuffer, OUTBUFFER_SIZE, pFrame); |
389 if (Packet.size < 0) |
399 if (Packet.size < 0) |
390 return FatalError("avcodec_encode_video failed"); |
400 return FatalError("avcodec_encode_video failed"); |
391 if (Packet.size == 0) |
401 if (Packet.size == 0) |