MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / LookForAudio

Function LookForAudio

libhb/scan.c:1462–1832  ·  view source on GitHub ↗

* This routine is called for every frame from a non-video elementary stream. * These are a mix of audio & subtitle streams, some of which we want & some * we're ignoring. This routine checks the frame against all our audio streams * to see if it's one we want and haven't identified yet. If yes, it passes the * frame to a codec-specific id routine which is responsible for filling in * the samp

Source from the content-addressed store, hash-verified

1460 * AC-3 audio).
1461 */
1462static void LookForAudio(hb_scan_t *scan, hb_title_t * title, hb_audio_t * audio, hb_buffer_t * b)
1463{
1464 if( !audio || audio->config.in.bitrate != 0 )
1465 {
1466 /* not found or already done */
1467 hb_buffer_close( &b );
1468 return;
1469 }
1470
1471 if ( audio->priv.scan_cache == NULL )
1472 audio->priv.scan_cache = hb_fifo_init( 16, 16 );
1473
1474 if ( hb_fifo_size_bytes( audio->priv.scan_cache ) >= 16384 )
1475 {
1476 hb_buffer_t * tmp;
1477 tmp = hb_fifo_get( audio->priv.scan_cache );
1478 hb_buffer_close( &tmp );
1479 }
1480 hb_fifo_push( audio->priv.scan_cache, b );
1481
1482 hb_work_object_t *w = hb_audio_decoder(scan->h, audio->config.in.codec);
1483
1484 if ( w == NULL || w->bsinfo == NULL )
1485 {
1486 hb_log( "Internal error in scan: unhandled audio type %d for id 0x%x",
1487 audio->config.in.codec, audio->id );
1488 goto drop_audio;
1489 }
1490
1491 hb_work_info_t info;
1492 w->title = title;
1493 w->audio = audio;
1494 w->codec_param = audio->config.in.codec_param;
1495 b = hb_fifo_see( audio->priv.scan_cache );
1496 int ret = w->bsinfo( w, b, &info );
1497 if ( ret < 0 && ret != AVERROR(EAGAIN) )
1498 {
1499 // No point in attempting to decode the
1500 // same data again the next time around
1501 hb_buffer_t * tmp;
1502 tmp = hb_fifo_get( audio->priv.scan_cache );
1503 hb_buffer_close( &tmp );
1504 av_channel_layout_uninit(info.ch_layout);
1505 free(info.ch_layout);
1506 free( w );
1507 audio->priv.scan_error_count++;
1508 return;
1509 }
1510 if ( !info.bitrate )
1511 {
1512 // didn't find any info
1513 // Additional buffer data may be required to obtain
1514 // audio attributes
1515 av_channel_layout_uninit(info.ch_layout);
1516 free(info.ch_layout);
1517 free( w );
1518 return;
1519 }

Callers 1

DecodePreviewsFunction · 0.85

Calls 13

hb_buffer_closeFunction · 0.85
hb_fifo_initFunction · 0.85
hb_fifo_size_bytesFunction · 0.85
hb_fifo_getFunction · 0.85
hb_fifo_pushFunction · 0.85
hb_audio_decoderFunction · 0.85
hb_logFunction · 0.85
hb_fifo_seeFunction · 0.85
hb_fifo_flushFunction · 0.85
hb_fifo_closeFunction · 0.85

Tested by

no test coverage detected