Search for SPS NALU rather than assuming its position
Summary: The implementation of H264AnnexBBufferHasVideoFormatDescription was assuming that the SPS NALU is either the first NALU in the stream, or the second one, in case an AUD NALU is present in the first location. This change removes this assumption and instead searches for the SPS NALU, failing only if we can't find one. In addition, it cleans up some binary buffer manipulation code, using the the parsed NALU indices we already have in AnnexBBufferReader instead. Test Plan: Unit tests Change-Id: Id9715aa1d751f0ba1a1992def2b690607896df56 bug: webrtc:8922 Change-Id: Id9715aa1d751f0ba1a1992def2b690607896df56 Reviewed-on: https://webrtc-review.googlesource.com/49982 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22205}
This commit is contained in:

committed by
Commit Bot

parent
0efa941d2f
commit
2fcb834bb4
@ -120,21 +120,17 @@ void decompressionOutputCallback(void *decoderRef,
|
||||
return WEBRTC_VIDEO_CODEC_NO_OUTPUT;
|
||||
}
|
||||
#endif
|
||||
if (webrtc::H264AnnexBBufferHasVideoFormatDescription((uint8_t *)inputImage.buffer.bytes,
|
||||
inputImage.buffer.length)) {
|
||||
rtc::ScopedCFTypeRef<CMVideoFormatDescriptionRef> inputFormat =
|
||||
rtc::ScopedCF(webrtc::CreateVideoFormatDescription((uint8_t *)inputImage.buffer.bytes,
|
||||
inputImage.buffer.length));
|
||||
if (inputFormat) {
|
||||
// Check if the video format has changed, and reinitialize decoder if
|
||||
// needed.
|
||||
if (!CMFormatDescriptionEqual(inputFormat.get(), _videoFormat)) {
|
||||
[self setVideoFormat:inputFormat.get()];
|
||||
|
||||
int resetDecompressionSessionError = [self resetDecompressionSession];
|
||||
if (resetDecompressionSessionError != WEBRTC_VIDEO_CODEC_OK) {
|
||||
return resetDecompressionSessionError;
|
||||
}
|
||||
rtc::ScopedCFTypeRef<CMVideoFormatDescriptionRef> inputFormat =
|
||||
rtc::ScopedCF(webrtc::CreateVideoFormatDescription((uint8_t *)inputImage.buffer.bytes,
|
||||
inputImage.buffer.length));
|
||||
if (inputFormat) {
|
||||
// Check if the video format has changed, and reinitialize decoder if
|
||||
// needed.
|
||||
if (!CMFormatDescriptionEqual(inputFormat.get(), _videoFormat)) {
|
||||
[self setVideoFormat:inputFormat.get()];
|
||||
int resetDecompressionSessionError = [self resetDecompressionSession];
|
||||
if (resetDecompressionSessionError != WEBRTC_VIDEO_CODEC_OK) {
|
||||
return resetDecompressionSessionError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user