Menu

#35 Patch for H.264 UDP problem

open
nobody
None
5
2008-12-23
2008-12-23
sensing
No

Modified TvideoCodecLibavformat.[cpp|h] as follows:

* Replaced all h264_has_start_code with codecId==CODEC_ID_H264
* Removed h264_has_start_code as class member variable
* removed isTSfile() as class member method
* changed ::append() to search for 0x00 00 01, rather than optional AU delimiters.

This fix works with all H.264 files, program streams, and transport streams. The original code had two branches: one branch went right to the h264_search_recovery code in the random access, the other waited to receive a CPB before sending it on through that h264_search_recovery() branch.

This is basically assuming that files are perfectly formed with no missing bytes, which would not be correct from a recorded H264 stream (an H264 VES stream sent through UDP could be missing packets).

At any rate, libavcodec seems to like complete NAL units, and it doesn't require complete coded picture buffers (CPB)s.

I'll implement the CPB patch if you'd like, but my testing has indicated it isn't strictly necessary.

Cheers,
Sensing

Discussion

  • sensing

    sensing - 2008-12-23

    Zipped TvideoCodecLibavcodec class files

     
  • sensing

    sensing - 2009-01-12

    I've added in the coded picture buffer detection. I only added in AUD and frame_num change detection, but the framework is all there to add the others if necessary. I left the isMPEG2system() method, but it isn't not used anymore. I hope this patch is sufficient for you!

    src/ffmpeg/libavcodec.def:
    * added avcodec_h264_find_cpb_boundary to export definitions

    src/ffmpeg/libavcodec/avcodec.h:
    * Modified avcodec_h264_search_recovery_point definition (added bytesUsed)
    * Added avcodec_h264_find_cpb_boundary method

    src/ffmpeg/libavcodec/h264.h: None

    src/ffmpeg/libavcodec/h264.c:
    * Modified avcodec_h264_search_recovery_point to return bytesUsed
    (for multiple nal searches across an input buffer)
    * Added function avcodec_h264_find_cpb_boundary()

    src/ffmpeg/Tlibavcodec.h:
    * Modified avcodec_h264_search_recovery_point definition (added bytesUsed)
    * Added avcodec_h264_find_cpb_boundary method

    src/ffmpeg/Tlibavcodec.cpp:
    * Added dll->loadFunction(avcodec_h264_find_cpb_boundary)

    src/codecs/TvideoCodecLibavcodec.h:
    * Th264RandomAccess:
    - added overloaded search function to maintain backwards compatibility
    * TcodedPictureBuffer
    - removed used_bytes member variable
    - added have_previous_data and prev_frame_num member variable

    src/codecs/TvideoCodecLibavcodec.cpp:
    * Modified TcodedPictureBuffer class (send() and append() methods).
    * Added overloaded search function in Th264RandomAccess to maintain backwards
    compatibility.

    File Added: ffdshow-patch.zip

     
  • sensing

    sensing - 2009-01-12

    Source code for patch

     

Log in to post a comment.