On 03/03/15 00:15, Thomas Volkert wrote:
> +    has_pic_id     = buf[0] & 0x80;
> +    has_layer_idc  = buf[0] & 0x40;
> +    has_ref_idc    = buf[0] & 0x20;
> +    first_fragment = buf[0] & 0x10;
> +    last_fragment  = buf[0] & 0x08;
> +    has_ss_data    = buf[0] & 0x04;
> +    has_su_data    = buf[0] & 0x02;
> +

if they are flags

flag = !!(buf[0] & mask);

might be nicer.

> +    /* sanity check for markers: B should always be equal to the RTP M 
> marker */
> +    if (last_fragment >> 2 != flags & RTP_FLAG_MARKER) {
> +        av_log(ctx, AV_LOG_ERROR, "Invalid combination of B and M marker\n");
> +        return AVERROR_INVALIDDATA;
> +    }

Might be night to print B and M here.

> +
> +    /* pass the extensions field */
> +    buf += RTP_VP9_DESC_REQUIRED_SIZE;
> +    len -= RTP_VP9_DESC_REQUIRED_SIZE;
> +
> +    /*
> +     *         decode the 1-byte/2-byte picture ID:
> +     *
> +     *          0 1 2 3 4 5 6 7
> +     *         +-+-+-+-+-+-+-+-+
> +     *   I:    |M|PICTURE ID   | (RECOMMENDED)
> +     *         +-+-+-+-+-+-+-+-+
> +     *   M:    | EXTENDED PID  | (RECOMMENDED)
> +     *         +-+-+-+-+-+-+-+-+
> +     *
> +     *   M: The most significant bit of the first octet is an extension flag.
> +     *   PictureID:  8 or 16 bits including the M bit.
> +     */
> +    if (has_pic_id) {
> +        if (len < 1) {
> +            av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
> +            return AVERROR_INVALIDDATA;
> +        }
> +
> +        /* check for 1-byte or 2-byte picture index */
> +        if (buf[0] & 0x80) {
> +            if (len < 2) {
> +                av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
> +                return AVERROR_INVALIDDATA;
> +            }
> +            pic_id = AV_RB16(buf) & 0x7fff;
> +            buf += 2;
> +            len -= 2;
> +        } else {
> +            pic_id = buf[0] & 0x7f;
> +            buf++;
> +            len--;
> +        }
> +    }
> +
> +    /*
> +     *         decode layer indices
> +     *
> +     *          0 1 2 3 4 5 6 7
> +     *         +-+-+-+-+-+-+-+-+
> +     *   L:    | T | S | Q | R | (CONDITIONALLY RECOMMENDED)
> +     *         +-+-+-+-+-+-+-+-+
> +     *
> +     *   T, S and Q are 2-bit indices for temporal, spatial, and quality 
> layers.
> +     *   If "F" is set in the initial octet, R is 2 bits representing the 
> number
> +     *   of reference fields this frame refers to.
> +     */
> +    if (has_layer_idc) {
> +        if (len < 1) {
> +            av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet");
> +            return AVERROR_INVALIDDATA;
> +        }
> +        layer_temporal = buf[0] & 0xC0;
> +        layer_spatial  = buf[0] & 0x30;
> +        layer_quality  = buf[0] & 0x0C;
> +        if (has_ref_idc) {
> +            ref_fields = buf[0] & 0x03;
> +            if (ref_fields)
> +                non_key_frame = 1;
> +        }
> +        buf++;
> +        len--;
> +    }
> +
> +    /*
> +     *         decode the reference fields
> +     *
> +     *          0 1 2 3 4 5 6 7
> +     *         +-+-+-+-+-+-+-+-+              -\
> +     *   F:    | PID |X| RS| RQ| (OPTIONAL)    .
> +     *         +-+-+-+-+-+-+-+-+               . - R times
> +     *   X:    | EXTENDED PID  | (OPTIONAL)    .
> +     *         +-+-+-+-+-+-+-+-+              -/
> +     *
> +     *   PID:  The relative Picture ID referred to by this frame.
> +     *   RS and RQ:  The spatial and quality layer IDs.
> +     *   X: 1 if this layer index has an extended relative Picture ID.
> +     */
> +    if (has_ref_idc) {
> +        while (ref_fields) {
> +            if (len < 1) {
> +                av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
> +                return AVERROR_INVALIDDATA;
> +            }
> +
> +            has_ref_field_ext_pic_id = buf[0] & 0x10;
> +
> +            /* pass ref. field */
> +            if (has_ref_field_ext_pic_id) {
> +                if (len < 2) {
> +                    av_log(ctx, AV_LOG_ERROR, "Too short RTP/VP9 packet\n");
> +                    return AVERROR_INVALIDDATA;
> +                }
> +
> +                /* ignore ref. data */
> +
> +                buf += 2;
> +                len -= 2;
> +            } else {
> +
> +                /* ignore ref. data */
> +
> +                buf++;
> +                len--;
> +            }
> +            ref_fields--;
> +        }
> +    }
> +
> +    /*
> +     *         decode the scalability structure (SS)
> +     *
> +     *          0 1 2 3 4 5 6 7
> +     *         +-+-+-+-+-+-+-+-+
> +     *   V:    | PATTERN LENGTH|
> +     *         +-+-+-+-+-+-+-+-+                           -\
> +     *         | T | S | Q | R | (OPTIONAL)                 .
> +     *         +-+-+-+-+-+-+-+-+              -\            .
> +     *         | PID |X| RS| RQ| (OPTIONAL)    .            . - PAT. LEN. 
> times
> +     *         +-+-+-+-+-+-+-+-+               . - R times  .
> +     *   X:    | EXTENDED PID  | (OPTIONAL)    .            .
> +     *         +-+-+-+-+-+-+-+-+              -/           -/
> +     *
> +     *   PID:  The relative Picture ID referred to by this frame.
> +     *   RS and RQ:  The spatial and quality layer IDs.
> +     *   X: 1 if this layer index has an extended relative Picture ID.
> +     */
> +    if (has_ss_data) {
> +        avpriv_report_missing_feature(ctx, "VP9 scalability structure 
> data\n");
> +        return AVERROR_PATCHWELCOME;
> +    }
> +
> +    /*
> +     * decode the scalability update structure (SU)
> +     *
> +     *  spec. is tbd
> +     */
> +    if (has_su_data) {
> +        avpriv_report_missing_feature(ctx, "VP9 scalability update structure 
> data\n");
> +        return AVERROR_PATCHWELCOME;
> +    }
> +

should be AVERROR(ENOSYS), report_missing_feature already prints a
similar message.

lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to