2012-01-30 12:50:16 +01:00
|
|
|
/*
|
2012-02-01 03:05:39 +01:00
|
|
|
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
|
2012-01-30 12:50:16 +01:00
|
|
|
*
|
2012-02-01 03:05:39 +01:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2012-01-30 12:50:16 +01:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2012-02-01 03:05:39 +01:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2012-01-30 12:50:16 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-01 03:05:39 +01:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2012-01-30 12:50:16 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "avcodec.h"
|
|
|
|
#include "dsputil.h"
|
|
|
|
#include "get_bits.h"
|
|
|
|
#include "golomb.h"
|
|
|
|
#include "put_bits.h"
|
|
|
|
|
|
|
|
#undef printf
|
|
|
|
#define COUNT 8000
|
2012-01-30 11:30:13 +01:00
|
|
|
#define SIZE (COUNT * 40)
|
2012-01-30 12:50:16 +01:00
|
|
|
|
2012-01-30 11:30:13 +01:00
|
|
|
int main(void)
|
|
|
|
{
|
2012-01-30 12:50:16 +01:00
|
|
|
int i;
|
|
|
|
uint8_t temp[SIZE];
|
|
|
|
PutBitContext pb;
|
|
|
|
GetBitContext gb;
|
|
|
|
|
|
|
|
init_put_bits(&pb, temp, SIZE);
|
|
|
|
printf("testing unsigned exp golomb\n");
|
2012-01-30 11:30:13 +01:00
|
|
|
for (i = 0; i < COUNT; i++)
|
2012-01-30 12:50:16 +01:00
|
|
|
set_ue_golomb(&pb, i);
|
|
|
|
flush_put_bits(&pb);
|
|
|
|
|
2012-01-30 11:30:13 +01:00
|
|
|
init_get_bits(&gb, temp, 8 * SIZE);
|
|
|
|
for (i = 0; i < COUNT; i++) {
|
2012-01-30 12:50:16 +01:00
|
|
|
int j, s = show_bits(&gb, 24);
|
|
|
|
|
2012-01-30 11:30:13 +01:00
|
|
|
j = get_ue_golomb(&gb);
|
|
|
|
if (j != i)
|
|
|
|
printf("mismatch at %d (%d should be %d) bits: %6X\n", i, j, i, s);
|
2012-01-30 12:50:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
init_put_bits(&pb, temp, SIZE);
|
|
|
|
printf("testing signed exp golomb\n");
|
2012-01-30 11:30:13 +01:00
|
|
|
for (i = 0; i < COUNT; i++)
|
|
|
|
set_se_golomb(&pb, i - COUNT / 2);
|
2012-01-30 12:50:16 +01:00
|
|
|
flush_put_bits(&pb);
|
|
|
|
|
2012-01-30 11:30:13 +01:00
|
|
|
init_get_bits(&gb, temp, 8 * SIZE);
|
|
|
|
for (i = 0; i < COUNT; i++) {
|
2012-01-30 12:50:16 +01:00
|
|
|
int j, s = show_bits(&gb, 24);
|
|
|
|
|
2012-01-30 11:30:13 +01:00
|
|
|
j = get_se_golomb(&gb);
|
|
|
|
if (j != i - COUNT / 2)
|
|
|
|
printf("mismatch at %d (%d should be %d) bits: %6X\n", i, j, i, s);
|
2012-01-30 12:50:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|