forked from mia/Aegisub
FFMS2:
Flag keyframes in generated packets more properly Requires FFmpeg r19078 to compile because of the changed define names Originally committed to SVN as r3005.
This commit is contained in:
parent
5fa6858d92
commit
ec297a5f11
3 changed files with 16 additions and 7 deletions
|
@ -453,7 +453,9 @@ int FFMatroskaAudio::DecodeNextAudioBlock(int64_t *Count, int AudioBlock, char *
|
||||||
TempPacket.data = MC.Buffer;
|
TempPacket.data = MC.Buffer;
|
||||||
TempPacket.size = FrameSize;
|
TempPacket.size = FrameSize;
|
||||||
if (Frames[AudioBlock].KeyFrame)
|
if (Frames[AudioBlock].KeyFrame)
|
||||||
TempPacket.flags = PKT_FLAG_KEY;
|
TempPacket.flags = AV_PKT_FLAG_KEY;
|
||||||
|
else
|
||||||
|
TempPacket.flags = 0;
|
||||||
|
|
||||||
while (TempPacket.size > 0) {
|
while (TempPacket.size > 0) {
|
||||||
int TempOutputBufSize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
int TempOutputBufSize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
||||||
|
@ -510,7 +512,7 @@ int FFHaaliAudio::DecodeNextAudioBlock(int64_t *AFirstStartTime, int64_t *Count,
|
||||||
Packet.data = Data;
|
Packet.data = Data;
|
||||||
Packet.size = pMMF->GetActualDataLength();
|
Packet.size = pMMF->GetActualDataLength();
|
||||||
if (pMMF->IsSyncPoint() == S_OK)
|
if (pMMF->IsSyncPoint() == S_OK)
|
||||||
Packet.flags = PKT_FLAG_KEY;
|
Packet.flags = AV_PKT_FLAG_KEY;
|
||||||
else
|
else
|
||||||
Packet.flags = 0;
|
Packet.flags = 0;
|
||||||
|
|
||||||
|
|
|
@ -528,9 +528,10 @@ int FFMatroskaVideo::DecodeNextFrame(int64_t *AFirstStartTime, char *ErrorMsg, u
|
||||||
Packet.data = MC.Buffer;
|
Packet.data = MC.Buffer;
|
||||||
Packet.size = FrameSize;
|
Packet.size = FrameSize;
|
||||||
if (FrameFlags & FRAME_KF)
|
if (FrameFlags & FRAME_KF)
|
||||||
Packet.flags = PKT_FLAG_KEY;
|
Packet.flags = AV_PKT_FLAG_KEY;
|
||||||
else
|
else
|
||||||
Packet.flags = 0;
|
Packet.flags = 0;
|
||||||
|
|
||||||
avcodec_decode_video2(CodecContext, DecodeFrame, &FrameFinished, &Packet);
|
avcodec_decode_video2(CodecContext, DecodeFrame, &FrameFinished, &Packet);
|
||||||
|
|
||||||
if (FrameFinished)
|
if (FrameFinished)
|
||||||
|
@ -768,7 +769,7 @@ int FFHaaliVideo::DecodeNextFrame(int64_t *AFirstStartTime, char *ErrorMsg, unsi
|
||||||
Packet.data = Data;
|
Packet.data = Data;
|
||||||
Packet.size = pMMF->GetActualDataLength();
|
Packet.size = pMMF->GetActualDataLength();
|
||||||
if (pMMF->IsSyncPoint() == S_OK)
|
if (pMMF->IsSyncPoint() == S_OK)
|
||||||
Packet.flags = PKT_FLAG_KEY;
|
Packet.flags = AV_PKT_FLAG_KEY;
|
||||||
else
|
else
|
||||||
Packet.flags = 0;
|
Packet.flags = 0;
|
||||||
|
|
||||||
|
|
|
@ -311,6 +311,10 @@ FFIndex *FFHaaliIndexer::DoIndexing(char *ErrorMsg, unsigned MsgSize) {
|
||||||
AVCodecContext *AudioCodecContext = AudioContexts[Track].CTX;
|
AVCodecContext *AudioCodecContext = AudioContexts[Track].CTX;
|
||||||
pMMF->GetPointer(&TempPacket.data);
|
pMMF->GetPointer(&TempPacket.data);
|
||||||
TempPacket.size = pMMF->GetActualDataLength();
|
TempPacket.size = pMMF->GetActualDataLength();
|
||||||
|
if (pMMF->IsSyncPoint() == S_OK)
|
||||||
|
TempPacket.flags = AV_PKT_FLAG_KEY;
|
||||||
|
else
|
||||||
|
TempPacket.flags = 0;
|
||||||
|
|
||||||
while (TempPacket.size > 0) {
|
while (TempPacket.size > 0) {
|
||||||
int dbsize = AVCODEC_MAX_AUDIO_FRAME_SIZE*10;
|
int dbsize = AVCODEC_MAX_AUDIO_FRAME_SIZE*10;
|
||||||
|
@ -453,7 +457,9 @@ FFIndex *FFMatroskaIndexer::DoIndexing(char *ErrorMsg, unsigned MsgSize) {
|
||||||
TempPacket.data = MC.Buffer;
|
TempPacket.data = MC.Buffer;
|
||||||
TempPacket.size = FrameSize;
|
TempPacket.size = FrameSize;
|
||||||
if ((FrameFlags & FRAME_KF) != 0)
|
if ((FrameFlags & FRAME_KF) != 0)
|
||||||
TempPacket.flags = PKT_FLAG_KEY;
|
TempPacket.flags = AV_PKT_FLAG_KEY;
|
||||||
|
else
|
||||||
|
TempPacket.flags = 0;
|
||||||
|
|
||||||
while (TempPacket.size > 0) {
|
while (TempPacket.size > 0) {
|
||||||
int dbsize = AVCODEC_MAX_AUDIO_FRAME_SIZE*10;
|
int dbsize = AVCODEC_MAX_AUDIO_FRAME_SIZE*10;
|
||||||
|
@ -594,9 +600,9 @@ FFIndex *FFLAVFIndexer::DoIndexing(char *ErrorMsg, unsigned MsgSize) {
|
||||||
|
|
||||||
// Only create index entries for video for now to save space
|
// Only create index entries for video for now to save space
|
||||||
if (FormatContext->streams[Packet.stream_index]->codec->codec_type == CODEC_TYPE_VIDEO) {
|
if (FormatContext->streams[Packet.stream_index]->codec->codec_type == CODEC_TYPE_VIDEO) {
|
||||||
(*TrackIndices)[Packet.stream_index].push_back(TFrameInfo(Packet.dts, (Packet.flags & PKT_FLAG_KEY) ? 1 : 0));
|
(*TrackIndices)[Packet.stream_index].push_back(TFrameInfo(Packet.dts, (Packet.flags & AV_PKT_FLAG_KEY) ? 1 : 0));
|
||||||
} else if (FormatContext->streams[Packet.stream_index]->codec->codec_type == CODEC_TYPE_AUDIO && (IndexMask & (1 << Packet.stream_index))) {
|
} else if (FormatContext->streams[Packet.stream_index]->codec->codec_type == CODEC_TYPE_AUDIO && (IndexMask & (1 << Packet.stream_index))) {
|
||||||
(*TrackIndices)[Packet.stream_index].push_back(TFrameInfo(Packet.dts, AudioContexts[Packet.stream_index].CurrentSample, (Packet.flags & PKT_FLAG_KEY) ? 1 : 0));
|
(*TrackIndices)[Packet.stream_index].push_back(TFrameInfo(Packet.dts, AudioContexts[Packet.stream_index].CurrentSample, (Packet.flags & AV_PKT_FLAG_KEY) ? 1 : 0));
|
||||||
AVCodecContext *AudioCodecContext = FormatContext->streams[Packet.stream_index]->codec;
|
AVCodecContext *AudioCodecContext = FormatContext->streams[Packet.stream_index]->codec;
|
||||||
TempPacket.data = Packet.data;
|
TempPacket.data = Packet.data;
|
||||||
TempPacket.size = Packet.size;
|
TempPacket.size = Packet.size;
|
||||||
|
|
Loading…
Reference in a new issue