MCPcopy Create free account
hub / github.com/FFMS/ffms2 / IndexAudioPacket

Method IndexAudioPacket

src/core/indexing.cpp:308–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308uint32_t FFMS_Indexer::IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices) {
309 AVCodecContext *CodecContext = Context.CodecContext;
310 int64_t StartSample = Context.CurrentSample;
311 int Ret = avcodec_send_packet(CodecContext, Packet);
312 if (Ret != 0) {
313 if (ErrorHandling == FFMS_IEH_ABORT) {
314 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_DECODING, "Audio decoding error");
315 } else if (ErrorHandling == FFMS_IEH_CLEAR_TRACK) {
316 TrackIndices[Track].clear();
317 IndexMask.erase(Track);
318 } else if (ErrorHandling == FFMS_IEH_STOP_TRACK) {
319 IndexMask.erase(Track);
320 }
321 }
322
323 while (true) {
324 av_frame_unref(DecodeFrame);
325 Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
326 if (Ret == 0) {
327 CheckAudioProperties(Track, CodecContext);
328 Context.CurrentSample += DecodeFrame->nb_samples;
329 } else if (Ret == AVERROR_EOF || Ret == AVERROR(EAGAIN)) {
330 break;
331 } else {
332 if (ErrorHandling == FFMS_IEH_ABORT) {
333 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_DECODING, "Audio decoding error");
334 } else if (ErrorHandling == FFMS_IEH_CLEAR_TRACK) {
335 TrackIndices[Track].clear();
336 IndexMask.erase(Track);
337 } else if (ErrorHandling == FFMS_IEH_STOP_TRACK) {
338 IndexMask.erase(Track);
339 }
340 }
341 }
342
343 return static_cast<uint32_t>(Context.CurrentSample - StartSample);
344}
345
346void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
347 auto it = LastAudioProperties.find(Track);

Callers

nothing calls this directly

Calls 2

FFMS_ExceptionClass · 0.85
clearMethod · 0.80

Tested by

no test coverage detected