Your original question: Does H.264 encoded video with BT.709 matrix include any gamma adjustment?
The encoded video only contains gamma adjustment – if you feed the encoder gamma adjusted values.
A H.264 encoder doesn’t care about the transfer characteristics.
So if you compress linear and then decompress – you’ll get linear.
So if you compress with gamma and then decompress – you’ll get gamma.
Or if your bits are encoded with a Rec. 709 transfer function – the encoder won’t change the gamma.
But you can specify the transfer characteristic in the H.264 stream as metadata. (Rec. ITU-T H.264 (04/2017) E.1.1 VUI parameters syntax). So the encoded streams carries the color space information around but it is not used in encoding or decoding.
I would assume that 8 bit video always contains a non linear transfer function. Otherwise you would use the 8 bit fairly unwisely.
If you convert to linear to do effects and composition – I’d recommend increasing the bit depth or linearizing into floats.
A color space consists of primaries, transfer function and matrix coefficients.
The gamma adjustment is encoded in the transfer function (and not in the matrix).