aizvorski / h264bitstream

A complete set of functions to read and write H.264 video bitstreams, in particular to examine or modify headers.
GNU Lesser General Public License v2.1
713 stars 237 forks source link

Fix errors in optional arg handling, and remove getopt dependency #9

Closed shervinemami closed 8 years ago

shervinemami commented 8 years ago

I noticed the program crashed whenever I tried using the optional args, such as: ./h264_analyze -p file.h264 ./h264_analyze -v 0 file.h264 ./h264_analyze -v 1 file.h264 ./h264_analyze file.h264 -p

So I fixed those bugs and cleaned up the arg handling code. Now all of the commands above should work. I also added an empty line between NAL units in the debug output, so it's easier to see each NAL unit.

aizvorski commented 8 years ago

Good catch! The crashes you found should now be fixed in 2a78e3c.

I am not sure about removing the getopt_long dependency in the way you did. This is hard to do without adding bugs (for example, try running your code with "./h264_analyze -"). Also it is reimplementing something that already exists and works well. Instead, I would prefer to distribute one of the BSD-licensed getopt implementations with this project.

shervinemami commented 8 years ago

Good idea. I've never used getopt before so I didn't know how to fix the code, I just knew how to replace it with plain C code, but it looks like your bugfix is even better. Thanks!