annotate libvo/vo_mpegpes.c @ 2200:1333f6184ad3

some ifno for cvs write owners
author arpi
date Sun, 14 Oct 2001 19:18:02 +0000
parents 2b14cad013b7
children b2ce5d6d7d4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1939
d8dc5e438965 10l cola Arpi =)
atmos4
parents: 1935
diff changeset
1 #undef HAVE_DVB
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
2 #define PES_MAX_SIZE 2048
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
3 /*
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
4 * Based on:
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
5 *
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
6 * test_av.c - Test program for new API
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
7 *
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
8 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
9 * & Marcus Metzler <marcus@convergence.de>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
10 * for convergence integrated media GmbH
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
11 *
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
12 * libav - MPEG-PS multiplexer, part of ffmpeg
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
13 * Copyright Gerard Lantau (see http://ffmpeg.sf.net)
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
14 *
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
15 */
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
16
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
17 #include <stdio.h>
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
18 #include <stdlib.h>
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
19 #include <string.h>
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
20
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
21 #include <sys/types.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
22 #include <sys/stat.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
23 #include <fcntl.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
24
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
25 #ifdef HAVE_DVB
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
26
2066
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
27 #include <sys/poll.h>
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
28
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
29 #include <sys/ioctl.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
30 #include <stdio.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
31 #include <time.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
32 #include <unistd.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
33
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
34 #include <ost/dmx.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
35 #include <ost/frontend.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
36 #include <ost/sec.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
37 #include <ost/video.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
38 #include <ost/audio.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
39
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
40 #endif
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
41
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
42 #include "config.h"
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
43 #include "video_out.h"
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
44 #include "video_out_internal.h"
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
45
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
46 LIBVO_EXTERN (mpegpes)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
47
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
48 int vo_mpegpes_fd=-1;
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
49 int vo_mpegpes_fd2=-1;
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
50
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
51 #ifdef USE_LIBAVCODEC
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
52
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
53 #include "../libavcodec/avcodec.h"
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
54
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
55 static unsigned char *picture_buf=NULL;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
56 static unsigned char *outbuf=NULL;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
57 static int outbuf_size = 100000;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
58
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
59 static int s_pos_x,s_pos_y;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
60 static int d_pos_x,d_pos_y;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
61
1943
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
62 static int osd_w,osd_h;
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
63
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
64 static AVPicture picture;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
65 static AVCodec *codec=NULL;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
66 static AVCodecContext codec_context;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
67 extern int avcodec_inited;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
68
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
69 #endif
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
70
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
71 static vo_info_t vo_info =
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
72 {
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
73 #ifdef HAVE_DVB
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
74 "Mpeg-PES to DVB card",
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
75 #else
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
76 "Mpeg-PES file",
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
77 #endif
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
78 "mpegpes",
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
79 "A'rpi",
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
80 ""
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
81 };
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
82
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
83 static uint32_t
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
84 init(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t height, uint32_t fullscreen, char *title, uint32_t format)
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
85 {
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
86 #ifdef HAVE_DVB
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
87 //|O_NONBLOCK
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
88 if((vo_mpegpes_fd = open("/dev/ost/video",O_RDWR)) < 0){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
89 perror("DVB VIDEO DEVICE: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
90 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
91 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
92 if((vo_mpegpes_fd2 = open("/dev/ost/audio",O_RDWR|O_NONBLOCK)) < 0){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
93 perror("DVB AUDIO DEVICE: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
94 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
95 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
96 if ( (ioctl(vo_mpegpes_fd,VIDEO_SET_BLANK, false) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
97 perror("DVB VIDEO SET BLANK: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
98 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
99 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
100 if ( (ioctl(vo_mpegpes_fd,VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
101 perror("DVB VIDEO SELECT SOURCE: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
102 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
103 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
104 #if 1
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
105 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
106 perror("DVB AUDIO SELECT SOURCE: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
107 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
108 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
109 if ( (ioctl(vo_mpegpes_fd2,AUDIO_PLAY) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
110 perror("DVB AUDIO PLAY: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
111 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
112 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
113 #else
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
114 if ( (ioctl(vo_mpegpes_fd2,AUDIO_STOP,0) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
115 perror("DVB AUDIO STOP: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
116 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
117 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
118 #endif
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
119 if ( (ioctl(vo_mpegpes_fd,VIDEO_PLAY) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
120 perror("DVB VIDEO PLAY: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
121 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
122 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
123 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_AV_SYNC, false) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
124 perror("DVB AUDIO SET AV SYNC: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
125 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
126 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
127 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_MUTE, false) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
128 perror("DVB AUDIO SET MUTE: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
129 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
130 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
131
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
132 #else
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
133 vo_mpegpes_fd=open("grab.mpg",O_WRONLY|O_CREAT);
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
134 if(vo_mpegpes_fd<0){
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
135 perror("vo_mpegpes");
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
136 return -1;
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
137 }
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
138 #endif
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
139
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
140 #ifdef USE_LIBAVCODEC
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
141 picture_buf=NULL;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
142 if(format==IMGFMT_YV12){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
143 int size;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
144
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
145 if(!avcodec_inited){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
146 avcodec_init();
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
147 avcodec_register_all();
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
148 avcodec_inited=1;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
149 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
150
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
151 /* find the mpeg1 video encoder */
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
152 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
153 if (!codec) {
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
154 fprintf(stderr, "mpeg1 codec not found\n");
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
155 return -1;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
156 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
157 memset(&codec_context,0,sizeof(codec_context));
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
158 codec_context.bit_rate=100000; // not used
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
159 codec_context.frame_rate=25*FRAME_RATE_BASE; // !!!!!
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
160 codec_context.gop_size=0; // I frames only
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
161 codec_context.flags=CODEC_FLAG_QSCALE;
1986
b1d663f54725 Y clipping fixed
arpi
parents: 1943
diff changeset
162 codec_context.quality=1; // quality! 1..31 (1=best,slowest)
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
163
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
164 #if 0
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
165 codec_context.width=width;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
166 codec_context.height=height;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
167 #else
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
168 if(width<=352 && height<=288){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
169 codec_context.width=352;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
170 codec_context.height=288;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
171 } else
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
172 if(width<=352 && height<=576){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
173 codec_context.width=352;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
174 codec_context.height=576;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
175 } else
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
176 if(width<=480 && height<=576){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
177 codec_context.width=480;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
178 codec_context.height=576;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
179 } else
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
180 if(width<=544 && height<=576){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
181 codec_context.width=544;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
182 codec_context.height=576;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
183 } else {
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
184 codec_context.width=704;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
185 codec_context.height=576;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
186 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
187 #endif
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
188
1943
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
189 osd_w=s_width;
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
190 d_pos_x=(codec_context.width-(int)s_width)/2;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
191 if(d_pos_x<0){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
192 s_pos_x=-d_pos_x;d_pos_x=0;
1943
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
193 osd_w=codec_context.width;
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
194 } else s_pos_x=0;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
195
1943
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
196 osd_h=s_height;
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
197 d_pos_y=(codec_context.height-(int)s_height)/2;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
198 if(d_pos_y<0){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
199 s_pos_y=-d_pos_y;d_pos_y=0;
1943
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
200 osd_h=codec_context.height;
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
201 } else s_pos_y=0;
1943
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
202
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
203 printf("[vo] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
204
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
205 /* open it */
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
206 if (avcodec_open(&codec_context, codec) < 0) {
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
207 fprintf(stderr, "could not open codec\n");
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
208 return -1;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
209 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
210
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
211 outbuf_size=10000+width*height; // must be enough!
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
212 outbuf = malloc(outbuf_size);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
213
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
214 size = codec_context.width*codec_context.height;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
215 picture_buf = malloc((size * 3) / 2); /* size for YUV 420 */
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
216
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
217 memset(picture_buf,0,size); // clear Y
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
218 memset(picture_buf+size,128,size/2); // clear UV
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
219
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
220 picture.data[0] = picture_buf;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
221 picture.data[1] = picture.data[0] + size;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
222 picture.data[2] = picture.data[1] + size / 4;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
223 picture.linesize[0] = codec_context.width;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
224 picture.linesize[1] = codec_context.width / 2;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
225 picture.linesize[2] = codec_context.width / 2;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
226
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
227 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
228 #endif
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
229 return 0;
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
230 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
231
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
232 static const vo_info_t*
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
233 get_info(void)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
234 {
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
235 return &vo_info;
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
236 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
237
1943
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
238 #ifdef USE_LIBAVCODEC
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
239 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
240 int x,y;
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
241 vo_draw_alpha_yv12(w,h,src,srca,stride,
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
242 picture.data[0]+(x0+d_pos_x)+(y0+d_pos_y)*picture.linesize[0],picture.linesize[0]);
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
243 }
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
244 #endif
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
245
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
246 static void draw_osd(void)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
247 {
1943
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
248 #ifdef USE_LIBAVCODEC
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
249 if(picture_buf){ // YV12 only:
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
250 vo_draw_text(osd_w,osd_h,draw_alpha);
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
251 }
24c248fbdb0f software OSD support
arpi
parents: 1939
diff changeset
252 #endif
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
253 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
254
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
255
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
256 static void my_write(unsigned char* data,int len){
2066
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
257 #ifdef HAVE_DVB
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
258 #define NFD 2
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
259 struct pollfd pfd[NFD];
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
260
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
261 // printf("write %d bytes \n",len);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
262
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
263 pfd[0].fd = vo_mpegpes_fd;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
264 pfd[0].events = POLLOUT;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
265
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
266 pfd[1].fd = vo_mpegpes_fd2;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
267 pfd[1].events = POLLOUT;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
268
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
269 while(len>0){
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
270 if (poll(pfd,NFD,1)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
271 if (pfd[0].revents & POLLOUT){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
272 int ret=write(vo_mpegpes_fd,data,len);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
273 // printf("ret=%d \n",ret);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
274 if(ret<=0){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
275 perror("write");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
276 usleep(0);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
277 } else {
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
278 len-=ret; data+=ret;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
279 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
280 } else usleep(1000);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
281 }
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
282 }
2066
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
283
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
284 #else
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
285 write(vo_mpegpes_fd,data,len); // write to file
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
286 #endif
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
287 }
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
288
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
289 static unsigned char pes_header[PES_MAX_SIZE];
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
290
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
291 static void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
292 int x;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
293
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
294 pes_header[0]=pes_header[1]=0;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
295 pes_header[2]=id>>8; pes_header[3]=id&255;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
296
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
297 while(1){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
298 int payload_size=len+5; // data + PTS
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
299 if(6+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-6;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
300
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
301 // construct PES header: (code from ffmpeg's libav)
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
302 // startcode:
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
303 // packetsize:
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
304 pes_header[4]=(payload_size)>>8;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
305 pes_header[5]=(payload_size)&255;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
306 // stuffing:
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
307 // presentation time stamp:
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
308 x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
309 pes_header[6]=x;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
310 x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
311 pes_header[7]=x>>8; pes_header[8]=x&255;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
312 x=((((timestamp) & 0x7fff) << 1) | 1);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
313 pes_header[9]=x>>8; pes_header[10]=x&255;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
314
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
315 payload_size-=5;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
316 memcpy(&pes_header[6+5],data,payload_size);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
317 my_write(pes_header,6+5+payload_size);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
318
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
319 len-=payload_size; data+=payload_size;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
320 if(len<=0) break;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
321 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
322
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
323 // printf("PES: draw frame! pts=%d size=%d \n",timestamp,len);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
324
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
325 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
326
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
327 static uint32_t draw_frame(uint8_t * src[])
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
328 {
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
329 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
330 unsigned char *data=p->data;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
331 // int tmp=-1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
332 send_pes_packet(p->data,p->size,p->id,p->timestamp); // video data
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
333 // send_pes_packet(&tmp,0,0x1C0,p->timestamp+30000); // fake audio data
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
334
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
335 return 0;
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
336 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
337
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
338 static void flip_page (void)
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
339 {
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
340 #ifdef USE_LIBAVCODEC
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
341 if(picture_buf){ // YV12 only:
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
342 int out_size;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
343 static int fno=0;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
344 /* encode the image */
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
345 out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
346 send_pes_packet(outbuf,out_size,0x1E0,fno*(90000/25));++fno;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
347 // printf("frame size: %d \n",out_size);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
348 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
349 #endif
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
350 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
351
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
352 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x0,int y0)
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
353 {
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
354 #ifdef USE_LIBAVCODEC
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
355 int y;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
356 unsigned char* s;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
357 unsigned char* d;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
358
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
359 x0+=d_pos_x;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
360 y0+=d_pos_y;
1986
b1d663f54725 Y clipping fixed
arpi
parents: 1943
diff changeset
361 if(x0+w>picture.linesize[0]) w=picture.linesize[0]-x0; // !!
b1d663f54725 Y clipping fixed
arpi
parents: 1943
diff changeset
362 if(y0+h>codec_context.height) h=codec_context.height-y0;
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
363
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
364 // Y
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
365 s=srcimg[0]+s_pos_x+s_pos_y*stride[0];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
366 d=picture.data[0]+x0+y0*picture.linesize[0];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
367 for(y=0;y<h;y++){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
368 memcpy(d,s,w);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
369 s+=stride[0];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
370 d+=picture.linesize[0];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
371 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
372
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
373 w/=2;h/=2;x0/=2;y0/=2;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
374
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
375 // U
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
376 s=srcimg[1]+(s_pos_x/2)+(s_pos_y/2)*stride[1];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
377 d=picture.data[1]+x0+y0*picture.linesize[1];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
378 for(y=0;y<h;y++){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
379 memcpy(d,s,w);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
380 s+=stride[1];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
381 d+=picture.linesize[1];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
382 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
383
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
384 // V
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
385 s=srcimg[2]+(s_pos_x/2)+(s_pos_y/2)*stride[2];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
386 d=picture.data[2]+x0+y0*picture.linesize[2];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
387 for(y=0;y<h;y++){
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
388 memcpy(d,s,w);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
389 s+=stride[2];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
390 d+=picture.linesize[2];
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
391 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
392 #endif
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
393 return 0;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
394 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
395
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
396
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
397 static uint32_t
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
398 query_format(uint32_t format)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
399 {
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
400 if(format==IMGFMT_MPEGPES) return 1;
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
401 #ifdef USE_LIBAVCODEC
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
402 if(format==IMGFMT_YV12) return 1;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
403 #endif
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
404 return 0;
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
405 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
406
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
407 static void
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
408 uninit(void)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
409 {
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
410 #ifdef USE_LIBAVCODEC
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
411 if(picture_buf){ // YV12 only:
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
412 free(outbuf);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
413 free(picture_buf);
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
414 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
415 #endif
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
416 if(vo_mpegpes_fd>=0){ close(vo_mpegpes_fd);vo_mpegpes_fd=-1;}
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
417 if(vo_mpegpes_fd2>=0){ close(vo_mpegpes_fd2);vo_mpegpes_fd2=-1;}
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
418 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
419
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
420
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
421 static void check_events(void)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
422 {
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
423 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
424