On Tue, Aug 06, 2013 at 06:23:51PM +0200, Christian Schmidt wrote:
> --- a/libavcodec/pcm-mpeg.c
> +++ b/libavcodec/pcm-mpeg.c
> @@ -29,6 +29,15 @@
>  #include "bytestream.h"
>  #include "internal.h"
>  
> +typedef struct PCMDVDContext {
> +    uint32_t last_header;    ///< Cached header to see if parsing is needed
> +    int block_size;          ///< Size of a block of samples in bytes
> +    int samples_per_block;   ///< Number of samples per channel per block
> +    int groups_per_block;    ///< Number of 20/24bit sammple groups per block
> +    uint8_t * extra_samples; ///< Pointer to leftover samples from a frame

*extra_samples, more cases below

> +    int extra_sample_count;  ///< Number of leftover samples in the buffer
> +} PCMDVDContext;

If this is only used within the file, the comments need not be Doxygen.

> @@ -302,6 +311,242 @@ static int pcm_bluray_decode_frame(AVCodecContext 
> *avctx, void *data,
> +static av_cold int pcm_dvd_decode_init(AVCodecContext * avctx)

*avctx

> +    /* reserve space for 8 channels, 3 bytes/sample, 4 samples/block */
> +    if (!(s->extra_samples = av_malloc (8*3*4)))

spaces around operators, no space before ( in function calls

> +    /* get the sample depth and derive the sample format from it */
> +    avctx->bits_per_coded_sample = 16 + ((header[1] >> 6) & 3) * 4;
> +
> +    /* get the sample rate */
> +    avctx->sample_rate = frequencies[(header[1] >> 4) & 3];

I'd drop the parentheses between >> and & as the precedence is
left-to-right anyway.

> +        case 4:
> +            /* one group has all the samples needed */
> +            s->block_size = 4 * avctx->bits_per_coded_sample / 8;
> +            s->samples_per_block = 4 / avctx->channels;
> +            s->groups_per_block = 1;
> +            break;
> +        case 8:
> +            /* two groups have all the samples needed */
> +            s->block_size = 8 * avctx->bits_per_coded_sample / 8;
> +            s->samples_per_block = 1;
> +            s->groups_per_block = 2;
> +            break;
> +        default:
> +            /* need avctx->channels groups */
> +            s->block_size = 4 * avctx->channels *
> +                            avctx->bits_per_coded_sample / 8;
> +            s->samples_per_block = 4;
> +            s->groups_per_block = avctx->channels;

Vertically align the = for better readability.

> +    /* consume leftover samples from last packet */
> +    if (s->extra_sample_count) {
> +        int missing_samples = s->block_size - s->extra_sample_count;
> +        if (buf_size >= missing_samples) {
> +            memcpy (s->extra_samples + s->extra_sample_count, src,
> +                    missing_samples);

no space before ( in function calls

> @@ -313,3 +558,18 @@ AVCodec ff_pcm_bluray_decoder = {
> +
> +AVCodec ff_pcm_dvd_decoder = {
> +    .name           = "pcm_dvd",
> +    .type           = AVMEDIA_TYPE_AUDIO,
> +    .id             = AV_CODEC_ID_PCM_DVD,
> +    .priv_data_size = sizeof(PCMDVDContext),
> +    .init           = pcm_dvd_decode_init,
> +    .decode         = pcm_dvd_decode_frame,
> +    .close          = pcm_dvd_decode_uninit,
> +    .capabilities   = CODEC_CAP_DR1,
> +    .sample_fmts    = (const enum AVSampleFormat[]){
> +        AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE
> +    },
> +    .long_name      = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit 
> big-endian for DVD media")

Move .long_name after .name.

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

Reply via email to