[x265] [PATCH] NAL : std::ostringstream replaced

Derek Buitenhuis derek.buitenhuis at gmail.com
Wed Sep 11 15:21:57 CEST 2013


On Wed, Sep 11, 2013 at 7:47 AM, Gopu Govindaswamy
<gopu at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Gopu Govindaswamy <gopu at multicorewareinc.com>
> # Date 1378882010 -19800
> # Node ID 275f2d5f9b0a782fd3ec36d95268545d96473e2e
> # Parent  af8cddab103e87cb7817e4809780a64573d4dad2
> NAL : std::ostringstream replaced

[...]

>      /** default constructor - no initialization; must be perfomed by user */
>      NALUnit() {}
> -
> +
>      /** returns true if the NALunit is a slice NALunit */

Unrelated whitespace change.

>      bool isSlice()
>      {
> @@ -105,7 +105,9 @@
>   */
>  struct NALUnitEBSP : public NALUnit
>  {
> -    std::ostringstream m_nalUnitData;
> +

Unrelated whitespace change.

> +    UInt m_packetSize;
> +    unsigned char *m_nalUnitData;

uint8_t? Why are you using unsigned char here? This is 2013.

> +    packetSize += bsNALUHeader.getByteStreamLength();
> +    out = (unsigned char *) malloc(packetSize * sizeof(unsigned char));

The sizeof() here is useless.

Also, why not X265_MALLOC?

> +    memcpy(out + packetSize, &(*rbsp.begin()), rbsp.end() - rbsp.begin());

I cannot remember if the memory buffer behind rbsp is guaranteed to be
contiguous under the C++ spec.

Please ignore if this is the case, otherwise, don't do that.


>              const NALUnitEBSP& nalu = **it;
>              int size = 0; /* size of annexB unit in bytes */
> -
> +
>              static const char start_code_prefix[] = { 0, 0, 0, 1 };

Unrelated whitespace change.

>
>              encoder->m_nals[nalcount].i_type = nalu.m_nalUnitType;
>              encoder->m_nals[nalcount].i_payload = size;
>              nalcount++;
> +            free(nalu.m_nalUnitData);

Not X264_FREE?

>              int size = 0; /* size of annexB unit in bytes */
> -
> +
>              static const char start_code_prefix[] = { 0, 0, 0, 1 };

More whitespace changes.

>              nalcount++;
> +            free(nalu.m_nalUnitData);
>          }

See above.

]]
>      else if (pi_nal)
>          *pi_nal = 0;
> +
>      return numEncoded;

Ditto.

- Derek


More information about the x265-devel mailing list