• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES
2#define VPX_CODEC_DISABLE_COMPAT 1
3#include "vpx/vpx_decoder.h"
4#include "vpx/vp8dx.h"
5#define interface (vpx_codec_vp8_dx())
6~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES
7
8
9~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DIE_CODEC
10static void die_codec(vpx_codec_ctx_t *ctx, const char *s) {
11    const char *detail = vpx_codec_error_detail(ctx);
12
13    printf("%s: %s\n", s, vpx_codec_error(ctx));
14    if(detail)
15        printf("    %s\n",detail);
16    exit(EXIT_FAILURE);
17}
18~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DIE_CODEC
19
20
21~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
22if(argc!=3)
23    die("Usage: %s <infile> <outfile>\n", argv[0]);
24~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
25
26
27~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INIT
28/* Initialize codec */
29if(vpx_codec_dec_init(&codec, interface, NULL, flags))
30    die_codec(&codec, "Failed to initialize decoder");
31~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INIT
32
33
34~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DECODE
35/* Decode the frame */
36if(vpx_codec_decode(&codec, frame, frame_sz, NULL, 0))
37    die_codec(&codec, "Failed to decode frame");
38~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DECODE
39
40
41~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GET_FRAME
42while((img = vpx_codec_get_frame(&codec, &iter))) {
43~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GET_FRAME
44
45
46~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX
47for(plane=0; plane < 3; plane++) {
48    unsigned char *buf =img->planes[plane];
49
50    for(y=0; y<img->d_h >> (plane?1:0); y++) {
51        if(fwrite(buf, 1, img->d_w >> (plane?1:0), outfile));
52        buf += img->stride[plane];
53    }
54}
55~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX
56
57
58~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY
59if(vpx_codec_destroy(&codec))
60    die_codec(&codec, "Failed to destroy codec");
61~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY
62