annotate libmpcodecs/vf_mirror.c @ 7743:a280cc3087ea

All right: The patch adresses two issues which I found, when I analyzed the input from some DVDs with known subtitle-dropouts: 1. The packet-size at the beginning of the packet, which is used to check, whether we got all fragments, is sometimes one byte too long. It seems to be always padded to an even number, while the actual size can be odd. 2. The original algorythm used to assemble the fragments relies on the timestamps to check, whether a new packet begins. This has proven to be unrelieable on some disks. So instead, I use the timestamp only to check, whether it's been too long (defined as 0,01sec) since the last fragment, which is probably indicating a broken packet, and normaly starting a new packet when the last one has been finished. patch by Christof Buergi <christof@buergi.lugs.ch>
author arpi
date Tue, 15 Oct 2002 00:47:17 +0000
parents a894e99c1e51
children 30f7df2d1bed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
1 #include <stdio.h>
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
2 #include <stdlib.h>
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
3 #include <string.h>
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
4 #include <inttypes.h>
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
5
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
6 #include "../config.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
7 #include "../mp_msg.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
8
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
9 #include "img_format.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
10 #include "mp_image.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
11 #include "vf.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
12
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
13 #include "../libvo/fastmemcpy.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
14 #include "../postproc/rgb2rgb.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
15
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
16
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
17 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp){
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
18 int y;
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
19 for(y=0;y<h;y++){
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
20 int x;
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
21 switch(bpp){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
22 case 1:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
23 for(x=0;x<w;x++) dst[x]=src[w-x-1];
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
24 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
25 case 2:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
26 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2));
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
27 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
28 case 3:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
29 for(x=0;x<w;x++){
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
30 dst[x*3+0]=src[0+(w-x-1)*3];
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
31 dst[x*3+1]=src[1+(w-x-1)*3];
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
32 dst[x*3+2]=src[2+(w-x-1)*3];
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
33 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
34 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
35 case 4:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
36 for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+(w-x-1)*4));
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
37 }
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
38 src+=srcstride;
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
39 dst+=dststride;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
40 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
41 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
42
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
43 //===========================================================================//
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
44
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 6539
diff changeset
45 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
46 mp_image_t *dmpi;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
47
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
48 // hope we'll get DR buffer:
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
49 dmpi=vf_get_image(vf->next,mpi->imgfmt,
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
50 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
51 mpi->w, mpi->h);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
52
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
53 if(mpi->flags&MP_IMGFLAG_PLANAR){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
54 mirror(dmpi->planes[0],mpi->planes[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
55 dmpi->stride[0],mpi->stride[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
56 dmpi->w,dmpi->h,1);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
57 mirror(dmpi->planes[1],mpi->planes[1],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
58 dmpi->stride[1],mpi->stride[1],
6539
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 5772
diff changeset
59 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1);
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
60 mirror(dmpi->planes[2],mpi->planes[2],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
61 dmpi->stride[2],mpi->stride[2],
6539
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 5772
diff changeset
62 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1);
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
63 } else {
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
64 mirror(dmpi->planes[0],mpi->planes[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
65 dmpi->stride[0],mpi->stride[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
66 dmpi->w,dmpi->h,dmpi->bpp>>3);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
67 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
68
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 6539
diff changeset
69 return vf_next_put_image(vf,dmpi);
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
70 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
71
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
72 //===========================================================================//
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
73
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
74 static int open(vf_instance_t *vf, char* args){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
75 //vf->config=config;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
76 vf->put_image=put_image;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
77 return 1;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
78 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
79
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
80 vf_info_t vf_info_mirror = {
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
81 "horizontal mirror",
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
82 "mirror",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
83 "Eyck",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
84 "",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
85 open
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
86 };
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
87
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
88 //===========================================================================//