annotate libvo/vo_dxr3.c @ 2888:7be29f66db55

--target and some Intel checks fixed
author gabucino
date Wed, 14 Nov 2001 00:19:22 +0000
parents 4f6190ab52e7
children ee37c7fc3022
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
1 #define PES_MAX_SIZE 2048
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
2 /*
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
3 * vo_dxr3.c - DXR3/H+ video out
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
4 *
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
5 * Copyright (C) 2001 David Holm <dholm@iname.com>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
6 *
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
7 * libav - MPEG-PS multiplexer, part of ffmpeg
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
8 * Copyright Gerard Lantau (see http://ffmpeg.sf.net)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
9 *
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
10 *
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
11 *
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
12 *
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
13 *
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
14 * *** NOTICE ***
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
15 * Further development of this device will be carried out using
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
16 * the new libvo2 system, meanwhile I hope someone can find where
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
17 * the lockup problem is located (caused by using subpics or audio
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
18 * (video gets blocked))
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
19 *
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
20 */
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
21
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
22 #include "fastmemcpy.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
23 #include <stdio.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
24 #include <stdlib.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
25 #include <string.h>
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
26 #include <linux/kernel.h>
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
27
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
28 #include <stdio.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
29 #include <time.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
30 #include <unistd.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
31
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
32 #include <libdxr3/api.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
33
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
34 #include "config.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
35 #include "video_out.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
36 #include "video_out_internal.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
37
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
38 #include "../postproc/rgb2rgb.h"
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
39 #ifdef HAVE_MMX
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
40 #include "mmx.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
41 #endif
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
42
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
43 LIBVO_EXTERN (dxr3)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
44
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
45 #ifdef USE_LIBAVCODEC
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
46
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
47 #ifdef USE_LIBAVCODEC_SO
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
48 #include <libffmpeg/avcodec.h>
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
49 #else
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
50 #include "../libavcodec/avcodec.h"
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
51 #endif
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
52 static AVPicture picture;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
53 static AVCodec *codec=NULL;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
54 static AVCodecContext codec_context;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
55 extern int avcodec_inited;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
56 #endif
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
57
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
58 static unsigned char *picture_buf=NULL;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
59 static unsigned char *outbuf=NULL;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
60 static unsigned char *spubuf=NULL;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
61 static int outbuf_size = 0;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
62 static int v_width,v_height;
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
63 static int s_width,s_height;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
64 static int s_pos_x,s_pos_y;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
65 static int d_pos_x,d_pos_y;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
66 static int osd_w,osd_h;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
67 static int img_format = 0;
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
68 static int palette[] = { 0x000000, 0x494949, 0xb5b5b5, 0xffffff };
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
69
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
70 static vo_info_t vo_info =
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
71 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
72 "DXR3/H+ video out",
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
73 "dxr3",
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
74 "David Holm <dholm@iname.com>",
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
75 ""
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
76 };
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
77
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
78 static uint32_t
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
79 init(uint32_t scr_width, uint32_t scr_height, uint32_t width, uint32_t height, uint32_t fullscreen, char *title, uint32_t format)
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
80 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
81 if( dxr3_get_status() == DXR3_STATUS_CLOSED )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
82 {
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
83 if( dxr3_open( "/dev/em8300" ) != 0 ) { printf( "Error opening /dev/em8300\n" ); return -1; }
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
84 printf( "DXR3 status: %s\n", dxr3_get_status() ? "opened":"closed" );
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
85 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
86
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
87 /* Subpic code isn't working yet, don't set to ON
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
88 unless you are really sure what you are doing */
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
89 dxr3_subpic_set_mode( DXR3_SPU_MODE_ON );
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
90 dxr3_subpic_set_palette( (char*)palette );
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
91 spubuf = malloc(53220); //53220bytes is the standardized max size of a subpic
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
92
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
93 if( dxr3_set_playmode( DXR3_PLAYMODE_PLAY ) !=0 ) printf( "Error setting playmode of DXR3\n" );
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
94
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
95 img_format = format;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
96 v_width = width;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
97 v_height = height;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
98 picture_buf=NULL;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
99
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
100 if( format == IMGFMT_YV12 )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
101 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
102 #ifdef USE_LIBAVCODEC
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
103
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
104 int size;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
105
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
106 printf("Format: YV12\n");
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
107
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
108 if(!avcodec_inited){
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
109 avcodec_init();
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
110 avcodec_register_all();
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
111 avcodec_inited=1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
112 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
113
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
114 /* find the mpeg1 video encoder */
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
115 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
116 if (!codec) {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
117 fprintf(stderr, "mpeg1 codec not found\n");
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
118 return -1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
119 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
120
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
121 memset(&codec_context,0,sizeof(codec_context));
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
122 codec_context.bit_rate=100000; // not used
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
123 codec_context.frame_rate=25*FRAME_RATE_BASE;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
124 codec_context.gop_size=0;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
125 codec_context.flags=CODEC_FLAG_QSCALE;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
126 codec_context.quality=1;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
127 codec_context.pix_fmt = PIX_FMT_YUV420P;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
128 if(width<=352 && height<=288){
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
129 codec_context.width=352;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
130 codec_context.height=288;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
131 } else
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
132 if(width<=352 && height<=576){
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
133 codec_context.width=352;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
134 codec_context.height=576;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
135 } else
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
136 if(width<=480 && height<=576){
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
137 codec_context.width=480;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
138 codec_context.height=576;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
139 } else
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
140 if(width<=544 && height<=576){
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
141 codec_context.width=544;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
142 codec_context.height=576;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
143 } else {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
144 codec_context.width=704;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
145 codec_context.height=576;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
146 }
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
147 s_width = codec_context.width;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
148 s_height = codec_context.height;;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
149
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
150
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
151 osd_w=scr_width;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
152 d_pos_x=(codec_context.width-(int)scr_width)/2;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
153 if(d_pos_x<0){
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
154 s_pos_x=-d_pos_x;d_pos_x=0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
155 osd_w=codec_context.width;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
156 } else s_pos_x=0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
157
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
158 osd_h=scr_height;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
159 d_pos_y=(codec_context.height-(int)scr_height)/2;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
160 if(d_pos_y<0){
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
161 s_pos_y=-d_pos_y;d_pos_y=0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
162 osd_h=codec_context.height;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
163 } else s_pos_y=0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
164
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
165 printf("[vo] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y);
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
166
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
167 /* open it */
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
168 if (avcodec_open(&codec_context, codec) < 0) {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
169 fprintf(stderr, "could not open codec\n");
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
170 return -1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
171 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
172
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
173 outbuf_size=10000+width*height;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
174 outbuf = malloc(outbuf_size);
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
175
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
176 size = codec_context.width*codec_context.height;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
177 picture_buf = malloc((size * 3)/2); /* size for YUV 420 */
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
178
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
179 picture.data[0] = picture_buf;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
180 picture.data[1] = picture.data[0] + size;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
181 picture.data[2] = picture.data[1] + size / 4;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
182 picture.linesize[0] = codec_context.width;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
183 picture.linesize[1] = codec_context.width / 2;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
184 picture.linesize[2] = codec_context.width / 2;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
185
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
186 return 0;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
187 #endif
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
188 return -1;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
189 }
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
190 else if(format==IMGFMT_BGR24)
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
191 {
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
192 #ifdef USE_LIBAVCODEC
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
193 int size = 0;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
194 printf("Format: BGR24\n");
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
195
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
196 if(!avcodec_inited)
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
197 {
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
198 avcodec_init();
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
199 avcodec_register_all();
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
200 avcodec_inited=1;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
201 }
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
202
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
203 /* find the mpeg1 video encoder */
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
204 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
205 if (!codec)
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
206 {
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
207 fprintf(stderr, "mpeg1 codec not found\n");
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
208 return -1;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
209 }
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
210
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
211 outbuf_size=10000+width*height;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
212 outbuf = malloc(outbuf_size);
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
213
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
214 memset(&codec_context,0,sizeof(codec_context));
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
215 codec_context.bit_rate=100000;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
216 codec_context.frame_rate=25*FRAME_RATE_BASE;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
217 codec_context.gop_size=0;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
218 codec_context.flags=CODEC_FLAG_QSCALE;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
219 codec_context.quality=1;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
220 codec_context.pix_fmt = PIX_FMT_YUV420P;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
221
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
222 /*if(width<=352 && height<=288){
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
223 codec_context.width=352;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
224 codec_context.height=288;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
225 } else
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
226 if(width<=352 && height<=576){
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
227 codec_context.width=352;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
228 codec_context.height=576;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
229 } else
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
230 if(width<=480 && height<=576){
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
231 codec_context.width=480;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
232 codec_context.height=576;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
233 } else
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
234 if(width<=544 && height<=576){
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
235 codec_context.width=544;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
236 codec_context.height=576;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
237 } else {
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
238 codec_context.width=704;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
239 codec_context.height=576;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
240 }*/
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
241 s_width = codec_context.width = width;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
242 s_height = codec_context.height = height;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
243
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
244 osd_w=scr_width;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
245 d_pos_x=(codec_context.width-(int)scr_width)/2;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
246 if(d_pos_x<0){
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
247 s_pos_x=-d_pos_x;d_pos_x=0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
248 osd_w=codec_context.width;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
249 } else s_pos_x=0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
250
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
251 osd_h=scr_height;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
252 d_pos_y=(codec_context.height-(int)scr_height)/2;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
253 if(d_pos_y<0){
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
254 s_pos_y=-d_pos_y;d_pos_y=0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
255 osd_h=codec_context.height;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
256 } else s_pos_y=0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
257
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
258 printf("[vo] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y);
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
259
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
260 /* open it */
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
261 if (avcodec_open(&codec_context, codec) < 0) {
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
262 fprintf(stderr, "could not open codec\n");
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
263 return -1;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
264 }
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
265
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
266 size = 10000+codec_context.width*codec_context.height;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
267 picture_buf = malloc((size * 3)/2);
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
268
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
269 picture.data[0] = picture_buf;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
270 picture.data[1] = picture.data[0] + size;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
271 picture.data[2] = picture.data[1] + size / 4;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
272 picture.linesize[0] = codec_context.width;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
273 picture.linesize[1] = codec_context.width / 2;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
274 picture.linesize[2] = codec_context.width / 2;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
275 return 0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
276 #endif
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
277 return -1;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
278 }
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
279 else if(format==IMGFMT_YUY2)
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
280 {
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
281 #ifdef USE_LIBAVCODEC
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
282 int size = 0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
283 printf("Format: YUY2\n");
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
284
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
285 if(!avcodec_inited)
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
286 {
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
287 avcodec_init();
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
288 avcodec_register_all();
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
289 avcodec_inited=1;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
290 }
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
291
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
292 /* find the mpeg1 video encoder */
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
293 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
294 if (!codec)
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
295 {
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
296 fprintf(stderr, "mpeg1 codec not found\n");
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
297 return -1;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
298 }
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
299
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
300 outbuf_size=10000+width*height;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
301 outbuf = malloc(outbuf_size);
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
302
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
303 memset(&codec_context,0,sizeof(codec_context));
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
304 codec_context.bit_rate=100000;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
305 codec_context.frame_rate=25*FRAME_RATE_BASE;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
306 codec_context.gop_size=0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
307 codec_context.flags=CODEC_FLAG_QSCALE;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
308 codec_context.quality=1;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
309 codec_context.pix_fmt = PIX_FMT_YUV420P;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
310
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
311 if(width<=352 && height<=288){
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
312 codec_context.width=352;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
313 codec_context.height=288;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
314 } else
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
315 if(width<=352 && height<=576){
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
316 codec_context.width=352;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
317 codec_context.height=576;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
318 } else
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
319 if(width<=480 && height<=576){
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
320 codec_context.width=480;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
321 codec_context.height=576;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
322 } else
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
323 if(width<=544 && height<=576){
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
324 codec_context.width=544;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
325 codec_context.height=576;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
326 } else {
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
327 codec_context.width=704;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
328 codec_context.height=576;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
329 }
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
330 s_width = codec_context.width;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
331 s_height = codec_context.height;;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
332 /* FOR DEBUGGING ONLY!! */
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
333 codec_context.width = width;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
334 codec_context.height = height;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
335
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
336 osd_w=scr_width;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
337 d_pos_x=(codec_context.width-(int)scr_width)/2;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
338 if(d_pos_x<0){
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
339 s_pos_x=-d_pos_x;d_pos_x=0;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
340 osd_w=codec_context.width;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
341 } else s_pos_x=0;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
342
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
343 osd_h=scr_height;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
344 d_pos_y=(codec_context.height-(int)scr_height)/2;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
345 if(d_pos_y<0){
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
346 s_pos_y=-d_pos_y;d_pos_y=0;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
347 osd_h=codec_context.height;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
348 } else s_pos_y=0;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
349
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
350 printf("[vo] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y);
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
351
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
352 /* open it */
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
353 if (avcodec_open(&codec_context, codec) < 0) {
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
354 fprintf(stderr, "could not open codec\n");
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
355 return -1;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
356 }
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
357
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
358 size = 10000+codec_context.width*codec_context.height;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
359 picture_buf = malloc((size * 3)/2);
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
360
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
361 picture.data[0] = picture_buf;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
362 picture.data[1] = picture.data[0] + size;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
363 picture.data[2] = picture.data[1] + size / 4;
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
364 picture.linesize[0] = codec_context.width;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
365 picture.linesize[1] = codec_context.width / 2;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
366 picture.linesize[2] = codec_context.width / 2;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
367 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
368 #endif
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
369 return -1;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
370 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
371 else if(format==IMGFMT_MPEGPES)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
372 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
373 printf( "Format: MPEG-PES\n" );
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
374 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
375 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
376
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
377 printf( "Format: Unsupported\n" );
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
378 return -1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
379 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
380
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
381 static const vo_info_t* get_info(void)
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
382 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
383 return &vo_info;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
384 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
385
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
386 static void draw_alpha(int x0, int y0, int w, int h, unsigned char* src, unsigned char *srca, int srcstride)
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
387 {
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
388 int x,y,index=0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
389 int n_rles=0, prev_nibbled=0, nibbled=0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
390 char prevcolor=0;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
391 unsigned char *dst = spubuf;
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
392 unsigned short *subpic_size, *cs_table;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
393 subpic_size = dst+=2;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
394 cs_table = dst+=2;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
395 prevcolor = src[0];
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
396 for( y = 0; y <= (h-1); y+=2 )
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
397 {
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
398 for( x = 0; x < w; x++ )
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
399 {
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
400 if( prevcolor == src[x+(y*w)] ) index++;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
401 else
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
402 {
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
403 if( prevcolor < 64 )
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
404 prevcolor = 0x00;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
405 else if( prevcolor < 128 )
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
406 prevcolor = 0x01;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
407 else if( prevcolor < 192 )
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
408 prevcolor = 0x02;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
409 else
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
410 prevcolor = 0x03;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
411 }
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
412 }
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
413 }
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
414
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
415 dxr3_subpic_write(spubuf,(dst-spubuf));
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
416 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
417
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
418 static void draw_osd(void)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
419 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
420 vo_draw_text(osd_w,osd_h,draw_alpha);
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
421 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
422
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
423 static uint32_t draw_frame(uint8_t * src[])
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
424 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
425 if( img_format == IMGFMT_MPEGPES )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
426 {
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
427 int data_left;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
428 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
429
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
430 data_left = p->size;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
431 while( data_left )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
432 data_left -= dxr3_video_write( &((unsigned char*)p->data)[p->size-data_left], data_left );
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
433
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
434 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
435 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
436 #ifdef USE_LIBAVCODEC
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
437 else if( img_format == IMGFMT_YV12 )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
438 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
439 printf("ERROR: Uninplemented\n");
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
440 }
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
441 else if( img_format == IMGFMT_BGR24 )
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
442 {
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
443 int tmp_size, out_size;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
444 int wrap, wrap3, x, y;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
445 int r, g, b, R, G, B, h = v_height, w = v_width;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
446 unsigned char *s, *Y, *U, *V;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
447
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
448 printf( "dS: %dx%d dD: %dx%d S: %dx%d V: %dx%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y,s_width,s_height,v_width,v_height);
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
449 if(d_pos_x+w>picture.linesize[0]) w=picture.linesize[0]-d_pos_x;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
450 if(d_pos_y+h>codec_context.height) h=codec_context.height-d_pos_y;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
451
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
452 Y = picture.data[0]+d_pos_x+(d_pos_y*picture.linesize[0]);
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
453 U = picture.data[1]+(d_pos_x/2)+((d_pos_y/2)*picture.linesize[1]);
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
454 V = picture.data[2]+(d_pos_x/2)+((d_pos_y/2)*picture.linesize[2]);
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
455
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
456 //BGR24->YUV420P from ffmpeg, see ffmpeg.sourceforge.net for terms of license
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
457 #define SCALEBITS 8
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
458 #define ONE_HALF (1 << (SCALEBITS - 1))
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
459 #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5))
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
460 wrap = s_width;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
461 wrap3 = w * 3;
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
462 s = src[0]+s_pos_x+(s_pos_y*wrap3);
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
463 for( y = 0; y < h; y+=2 )
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
464 {
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
465 for( x = 0; x < w; x+=2 )
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
466 {
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
467 b = s[0];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
468 g = s[1];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
469 r = s[2];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
470 R = r;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
471 G = g;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
472 B = b;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
473 Y[0] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
474 b = s[3];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
475 g = s[4];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
476 r = s[5];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
477 R += r;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
478 G += g;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
479 B += b;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
480 Y[1] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
481 s += wrap3;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
482 Y += wrap;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
483
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
484 b = s[0];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
485 g = s[1];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
486 r = s[2];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
487 R += r;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
488 G += g;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
489 B += b;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
490 Y[0] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
491 b = s[3];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
492 g = s[4];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
493 r = s[5];
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
494 R += r;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
495 G += g;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
496 B += b;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
497 Y[1] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
498 U[0] = ((- FIX(0.16874) * R - FIX(0.33126) * G - FIX(0.50000) * B + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
499 V[0] = ((FIX(0.50000) * R - FIX(0.41869) * G - FIX(0.08131) * B + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
500
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
501 U++;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
502 V++;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
503 s -= (wrap3-6);
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
504 Y -= (wrap-(3/2));
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
505 }
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
506 s += wrap3;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
507 Y += wrap;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
508 }
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
509 #undef SCALEBITS
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
510 #undef ONE_HALF
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
511 #undef FIX(x)
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
512 //End of ffmpeg code, see ffmpeg.sourceforge.net for terms of license
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
513 tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture);
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
514 while( out_size )
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
515 out_size -= dxr3_video_write( &outbuf[tmp_size-out_size], out_size );
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
516 return 0;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
517 }
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
518 else if( img_format == IMGFMT_YUY2 )
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
519 {
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
520 int tmp_size, out_size;
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
521 tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture);
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
522 while( out_size )
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
523 out_size -= dxr3_video_write( &outbuf[tmp_size-out_size], out_size );
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
524
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
525 return 0;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
526 }
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
527 #endif
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
528
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
529 printf( "Error in draw_frame(...)\n" );
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
530 return -1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
531 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
532
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
533 static void flip_page (void)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
534 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
535 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
536
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
537 static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
538 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
539 int y;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
540 unsigned char* s;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
541 unsigned char* d;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
542 int data_left;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
543 vo_mpegpes_t *p = (vo_mpegpes_t *)srcimg[0];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
544
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
545 if( img_format == IMGFMT_YV12 )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
546 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
547 #ifdef USE_LIBAVCODEC
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
548 int out_size, tmp_size;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
549 x0+=d_pos_x;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
550 y0+=d_pos_y;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
551 if(x0+w>picture.linesize[0]) w=picture.linesize[0]-x0; // !!
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
552 if(y0+h>codec_context.height) h=codec_context.height-y0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
553
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
554 // Y
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
555 s=srcimg[0]+s_pos_x+s_pos_y*stride[0];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
556 d=picture.data[0]+x0+y0*picture.linesize[0];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
557 for( y = 0; y < h; y++)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
558 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
559 memcpy(d,s,w);
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
560 s+=stride[0];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
561 d+=picture.linesize[0];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
562 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
563
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
564 w/=2;h/=2;x0/=2;y0/=2;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
565
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
566 // U
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
567 s=srcimg[1]+(s_pos_x/2)+(s_pos_y/2)*stride[1];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
568 d=picture.data[1]+x0+y0*picture.linesize[1];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
569 for( y = 0; y < h; y++)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
570 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
571 memcpy(d,s,w);
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
572 s+=stride[1];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
573 d+=picture.linesize[1];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
574 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
575
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
576 // V
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
577 s=srcimg[2]+(s_pos_x/2)+(s_pos_y/2)*stride[2];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
578 d=picture.data[2]+x0+y0*picture.linesize[2];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
579 for(y=0;y<h;y++)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
580 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
581 memcpy(d,s,w);
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
582 s+=stride[2];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
583 d+=picture.linesize[2];
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
584 }
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
585
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
586 tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture);
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
587 while( out_size )
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
588 out_size -= dxr3_video_write( &outbuf[tmp_size-out_size], out_size );
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
589
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
590 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
591 #endif
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
592 return -1;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
593 }
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
594 else if( img_format == IMGFMT_BGR24 )
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
595 {
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
596 return -1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
597 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
598 else if( img_format == IMGFMT_MPEGPES )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
599 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
600 data_left = p->size;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
601 while( data_left )
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
602 data_left -= dxr3_video_write( &((unsigned char*)p->data)[p->size-data_left], data_left );
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
603 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
604 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
605
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
606 return -1;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
607 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
608
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
609
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
610 static uint32_t
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
611 query_format(uint32_t format)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
612 {
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
613 if(format==IMGFMT_MPEGPES) return 0x2|0x4;
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
614 #ifdef USE_LIBAVCODEC
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
615 if(format==IMGFMT_YV12) return 0x1|0x4;
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
616 if(format==IMGFMT_YUY2) return 0x1|0x4;
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
617 if(format==IMGFMT_BGR24) return 0x1|0x4;
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
618 #else
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
619 if(format==IMGFMT_YV12) {printf("You need to compile with libavcodec or ffmpeg.so to play this file!\n" ); return 0;}
2866
4f6190ab52e7 Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents: 2770
diff changeset
620 if(format==IMGFMT_YUY2) {printf("You need to compile with libavcodec or ffmpeg.so to play this file!\n" ); return 0;}
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
621 if(format==IMGFMT_BGR24) {printf("You need to compile with libavcodec or ffmpeg.so to play this file!\n" ); return 0;}
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
622 #endif
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
623 return 0;
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
624 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
625
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
626 static void
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
627 uninit(void)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
628 {
2770
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
629 free(outbuf);
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
630 free(picture_buf);
b9732eaa82d9 DXR3 beta2 patch by David Holm.
atmos4
parents: 2732
diff changeset
631 free(spubuf);
2645
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
632 dxr3_close( );
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
633 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
634
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
635
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
636 static void check_events(void)
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
637 {
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
638 }
9d8d69fc517c ao_dxr3 by David Holm <dholm@telia.com>
arpi
parents:
diff changeset
639