Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

h.264 bytestream parsing

The input data is a byte array which represents a h.264 frame. The frame consists of a single slice (not multislice frame).

So, as I understood I can cope with this frame as with slice. The slice has header, and slice data - macroblocks, each macroblock with its own header.

So I have to parse that byte array to extract frame number, frame type, quantisation coefficient (as I understood each macroblock has its own coefficient? or I'm wrong?)

Could You advise me, where I can get more detailed information about parsing h.264 frame bytes.

(In fact I've read the standard, but it wasn't very specific, and I'm lost.)

Thanks

like image 487
stemm Avatar asked Nov 27 '22 22:11

stemm


1 Answers

The H.264 Standard is a bit hard to read, so here are some tips.

  • Read Annex B; make sure your input starts with a start code
  • Read section 9.1: you will need it for all of the following
  • Slice header is described in section 7.3.3
  • "Frame number" is not encoded explicitly in the slice header; frame_num is close to what you probably want.
  • "Frame type" probably corresponds to slice_type (the second value in the slice header, so most easy to parse; you should definitely start with this one)
  • "Quantization coefficient" - do you mean "quantization parameter"? If yes, be prepared to write a full H.264 parser (or reuse an existing one). Look in section 9.3 to get an idea on a complexity of a H.264 parser.
like image 95
anatolyg Avatar answered Dec 12 '22 14:12

anatolyg