Mercurial > mplayer.hg
annotate libmpcodecs/vf_pullup.c @ 27739:c59e6672574e
Remove some pointless and/or outdated codec documentation sections.
author | diego |
---|---|
date | Tue, 14 Oct 2008 22:28:52 +0000 |
parents | 5804605d4341 |
children | 0f1b5b68af32 |
rev | line source |
---|---|
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
1 #include <stdio.h> |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
2 #include <stdlib.h> |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
3 #include <string.h> |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
4 |
17012 | 5 #include "config.h" |
6 #include "mp_msg.h" | |
7 #include "cpudetect.h" | |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
8 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
9 #include "img_format.h" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
10 #include "mp_image.h" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
11 #include "vf.h" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
12 |
17012 | 13 #include "libvo/fastmemcpy.h" |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
14 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
15 #include "pullup.h" |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
16 |
12548
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
17 #undef MAX |
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
18 #define MAX(a,b) ((a)>(b)?(a):(b)) |
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
19 |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
20 struct vf_priv_s { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
21 struct pullup_context *ctx; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
22 int init; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
23 int fakecount; |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
24 char *qbuf; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
25 }; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
26 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
27 static void init_pullup(struct vf_instance_s* vf, mp_image_t *mpi) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
28 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
29 struct pullup_context *c = vf->priv->ctx; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
30 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
31 if (mpi->flags & MP_IMGFLAG_PLANAR) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
32 c->format = PULLUP_FMT_Y; |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
33 c->nplanes = 4; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
34 pullup_preinit_context(c); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
35 c->bpp[0] = c->bpp[1] = c->bpp[2] = 8; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
36 c->w[0] = mpi->w; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
37 c->h[0] = mpi->h; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
38 c->w[1] = c->w[2] = mpi->chroma_width; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
39 c->h[1] = c->h[2] = mpi->chroma_height; |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
40 c->w[3] = ((mpi->w+15)/16) * ((mpi->h+15)/16); |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
41 c->h[3] = 2; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
42 c->stride[0] = mpi->width; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
43 c->stride[1] = c->stride[2] = mpi->chroma_width; |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
44 c->stride[3] = c->w[3]; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
45 c->background[1] = c->background[2] = 128; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
46 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
47 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
48 if (gCpuCaps.hasMMX) c->cpu |= PULLUP_CPU_MMX; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
49 if (gCpuCaps.hasMMX2) c->cpu |= PULLUP_CPU_MMX2; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
50 if (gCpuCaps.has3DNow) c->cpu |= PULLUP_CPU_3DNOW; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
51 if (gCpuCaps.has3DNowExt) c->cpu |= PULLUP_CPU_3DNOWEXT; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
52 if (gCpuCaps.hasSSE) c->cpu |= PULLUP_CPU_SSE; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
53 if (gCpuCaps.hasSSE2) c->cpu |= PULLUP_CPU_SSE2; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
54 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
55 pullup_init_context(c); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
56 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
57 vf->priv->init = 1; |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
58 vf->priv->qbuf = malloc(c->w[3]); |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
59 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
60 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
61 |
24603
4d4c5efcfdb0
Disable buggy unused function via #if 0, blessed by Rich.
diego
parents:
23666
diff
changeset
|
62 #if 0 |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
63 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
64 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
65 struct pullup_context *c = vf->priv->ctx; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
66 struct pullup_buffer *b; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
67 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
68 if (mpi->type == MP_IMGTYPE_STATIC) return; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
69 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
70 if (!vf->priv->init) init_pullup(vf, mpi); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
71 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
72 b = pullup_get_buffer(c, 2); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
73 if (!b) return; /* shouldn't happen... */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
74 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
75 mpi->priv = b; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
76 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
77 mpi->planes[0] = b->planes[0]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
78 mpi->planes[1] = b->planes[1]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
79 mpi->planes[2] = b->planes[2]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
80 mpi->stride[0] = c->stride[0]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
81 mpi->stride[1] = c->stride[1]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
82 mpi->stride[2] = c->stride[2]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
83 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
84 mpi->flags |= MP_IMGFLAG_DIRECT; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
85 mpi->flags &= ~MP_IMGFLAG_DRAW_CALLBACK; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
86 } |
24603
4d4c5efcfdb0
Disable buggy unused function via #if 0, blessed by Rich.
diego
parents:
23666
diff
changeset
|
87 #endif |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
88 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
89 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
90 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
91 struct pullup_context *c = vf->priv->ctx; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
92 struct pullup_buffer *b; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
93 struct pullup_frame *f; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
94 mp_image_t *dmpi; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
95 int ret; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
96 int p; |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
97 int i; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
98 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
99 if (!vf->priv->init) init_pullup(vf, mpi); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
100 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
101 if (mpi->flags & MP_IMGFLAG_DIRECT) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
102 b = mpi->priv; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
103 mpi->priv = 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
104 } else { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
105 b = pullup_get_buffer(c, 2); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
106 if (!b) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
107 mp_msg(MSGT_VFILTER,MSGL_ERR,"Could not get buffer from pullup!\n"); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
108 f = pullup_get_frame(c); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
109 pullup_release_frame(f); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
110 return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
111 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
112 memcpy_pic(b->planes[0], mpi->planes[0], mpi->w, mpi->h, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
113 c->stride[0], mpi->stride[0]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
114 if (mpi->flags & MP_IMGFLAG_PLANAR) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
115 memcpy_pic(b->planes[1], mpi->planes[1], |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
116 mpi->chroma_width, mpi->chroma_height, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
117 c->stride[1], mpi->stride[1]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
118 memcpy_pic(b->planes[2], mpi->planes[2], |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
119 mpi->chroma_width, mpi->chroma_height, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
120 c->stride[2], mpi->stride[2]); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
121 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
122 } |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
123 if (mpi->qscale) { |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
17906
diff
changeset
|
124 fast_memcpy(b->planes[3], mpi->qscale, c->w[3]); |
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
17906
diff
changeset
|
125 fast_memcpy(b->planes[3]+c->w[3], mpi->qscale, c->w[3]); |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
126 } |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
127 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
128 p = mpi->fields & MP_IMGFIELD_TOP_FIRST ? 0 : |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
129 (mpi->fields & MP_IMGFIELD_ORDERED ? 1 : 0); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
130 pullup_submit_field(c, b, p); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
131 pullup_submit_field(c, b, p^1); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
132 if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
133 pullup_submit_field(c, b, p); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
134 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
135 pullup_release_buffer(b, 2); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
136 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
137 f = pullup_get_frame(c); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
138 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
139 /* Fake yes for first few frames (buffer depth) to keep from |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
140 * breaking A/V sync with G1's bad architecture... */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
141 if (!f) return vf->priv->fakecount ? (--vf->priv->fakecount,1) : 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
142 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
143 if (f->length < 2) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
144 pullup_release_frame(f); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
145 f = pullup_get_frame(c); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
146 if (!f) return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
147 if (f->length < 2) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
148 pullup_release_frame(f); |
14954
fe1dfcfcc3bf
1000l to me: could break a/v sync and eventually cause buffer exhaustion on soft-telecined input that's ugly
rfelker
parents:
13267
diff
changeset
|
149 if (!(mpi->fields & MP_IMGFIELD_REPEAT_FIRST)) |
fe1dfcfcc3bf
1000l to me: could break a/v sync and eventually cause buffer exhaustion on soft-telecined input that's ugly
rfelker
parents:
13267
diff
changeset
|
150 return 0; |
fe1dfcfcc3bf
1000l to me: could break a/v sync and eventually cause buffer exhaustion on soft-telecined input that's ugly
rfelker
parents:
13267
diff
changeset
|
151 f = pullup_get_frame(c); |
fe1dfcfcc3bf
1000l to me: could break a/v sync and eventually cause buffer exhaustion on soft-telecined input that's ugly
rfelker
parents:
13267
diff
changeset
|
152 if (!f) return 0; |
fe1dfcfcc3bf
1000l to me: could break a/v sync and eventually cause buffer exhaustion on soft-telecined input that's ugly
rfelker
parents:
13267
diff
changeset
|
153 if (f->length < 2) { |
fe1dfcfcc3bf
1000l to me: could break a/v sync and eventually cause buffer exhaustion on soft-telecined input that's ugly
rfelker
parents:
13267
diff
changeset
|
154 pullup_release_frame(f); |
fe1dfcfcc3bf
1000l to me: could break a/v sync and eventually cause buffer exhaustion on soft-telecined input that's ugly
rfelker
parents:
13267
diff
changeset
|
155 return 0; |
fe1dfcfcc3bf
1000l to me: could break a/v sync and eventually cause buffer exhaustion on soft-telecined input that's ugly
rfelker
parents:
13267
diff
changeset
|
156 } |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
157 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
158 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
159 |
12548
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
160 #if 0 |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
161 /* Average qscale tables from both frames. */ |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
162 if (mpi->qscale) { |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
163 for (i=0; i<c->w[3]; i++) { |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
164 vf->priv->qbuf[i] = (f->ofields[0]->planes[3][i] |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
165 + f->ofields[1]->planes[3][i+c->w[3]])>>1; |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
166 } |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
167 } |
12548
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
168 #else |
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
169 /* Take worst of qscale tables from both frames. */ |
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
170 if (mpi->qscale) { |
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
171 for (i=0; i<c->w[3]; i++) { |
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
172 vf->priv->qbuf[i] = MAX(f->ofields[0]->planes[3][i], f->ofields[1]->planes[3][i+c->w[3]]); |
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
173 } |
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
174 } |
8584fdad0188
old changes in my local tree i forgot to commit - minor fixes
rfelker
parents:
11629
diff
changeset
|
175 #endif |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
176 |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
177 /* If the frame isn't already exportable... */ |
10773
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
178 while (!f->buffer) { |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
179 dmpi = vf_get_image(vf->next, mpi->imgfmt, |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
180 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
181 mpi->width, mpi->height); |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
182 /* FIXME: Is it ok to discard dmpi if it's not direct? */ |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
183 if (!(dmpi->flags & MP_IMGFLAG_DIRECT)) { |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
184 pullup_pack_frame(c, f); |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
185 break; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
186 } |
10773
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
187 /* Direct render fields into output buffer */ |
11628
6fc547235443
simplified frame decision logic and reduced the occurrance of length=1
rfelker
parents:
10956
diff
changeset
|
188 my_memcpy_pic(dmpi->planes[0], f->ofields[0]->planes[0], |
10773
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
189 mpi->w, mpi->h/2, dmpi->stride[0]*2, c->stride[0]*2); |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
190 my_memcpy_pic(dmpi->planes[0] + dmpi->stride[0], |
11628
6fc547235443
simplified frame decision logic and reduced the occurrance of length=1
rfelker
parents:
10956
diff
changeset
|
191 f->ofields[1]->planes[0] + c->stride[0], |
10773
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
192 mpi->w, mpi->h/2, dmpi->stride[0]*2, c->stride[0]*2); |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
193 if (mpi->flags & MP_IMGFLAG_PLANAR) { |
11628
6fc547235443
simplified frame decision logic and reduced the occurrance of length=1
rfelker
parents:
10956
diff
changeset
|
194 my_memcpy_pic(dmpi->planes[1], f->ofields[0]->planes[1], |
10773
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
195 mpi->chroma_width, mpi->chroma_height/2, |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
196 dmpi->stride[1]*2, c->stride[1]*2); |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
197 my_memcpy_pic(dmpi->planes[1] + dmpi->stride[1], |
11628
6fc547235443
simplified frame decision logic and reduced the occurrance of length=1
rfelker
parents:
10956
diff
changeset
|
198 f->ofields[1]->planes[1] + c->stride[1], |
10773
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
199 mpi->chroma_width, mpi->chroma_height/2, |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
200 dmpi->stride[1]*2, c->stride[1]*2); |
11628
6fc547235443
simplified frame decision logic and reduced the occurrance of length=1
rfelker
parents:
10956
diff
changeset
|
201 my_memcpy_pic(dmpi->planes[2], f->ofields[0]->planes[2], |
10773
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
202 mpi->chroma_width, mpi->chroma_height/2, |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
203 dmpi->stride[2]*2, c->stride[2]*2); |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
204 my_memcpy_pic(dmpi->planes[2] + dmpi->stride[2], |
11628
6fc547235443
simplified frame decision logic and reduced the occurrance of length=1
rfelker
parents:
10956
diff
changeset
|
205 f->ofields[1]->planes[2] + c->stride[2], |
10773
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
206 mpi->chroma_width, mpi->chroma_height/2, |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
207 dmpi->stride[2]*2, c->stride[2]*2); |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
208 } |
012eeac10e16
direct render frames whose fields are not in a common buffer, rather
rfelker
parents:
10738
diff
changeset
|
209 pullup_release_frame(f); |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
210 if (mpi->qscale) { |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
211 dmpi->qscale = vf->priv->qbuf; |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
212 dmpi->qstride = mpi->qstride; |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
213 dmpi->qscale_type = mpi->qscale_type; |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
214 } |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
215 return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
216 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
217 dmpi = vf_get_image(vf->next, mpi->imgfmt, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
218 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
219 mpi->width, mpi->height); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
220 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
221 dmpi->planes[0] = f->buffer->planes[0]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
222 dmpi->planes[1] = f->buffer->planes[1]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
223 dmpi->planes[2] = f->buffer->planes[2]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
224 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
225 dmpi->stride[0] = c->stride[0]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
226 dmpi->stride[1] = c->stride[1]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
227 dmpi->stride[2] = c->stride[2]; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
228 |
11629
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
229 if (mpi->qscale) { |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
230 dmpi->qscale = vf->priv->qbuf; |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
231 dmpi->qstride = mpi->qstride; |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
232 dmpi->qscale_type = mpi->qscale_type; |
341f3c870013
pass quantizer tables through (averaging values when fields come from
rfelker
parents:
11628
diff
changeset
|
233 } |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
234 ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
235 pullup_release_frame(f); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
236 return ret; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
237 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
238 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
239 static int query_format(struct vf_instance_s* vf, unsigned int fmt) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
240 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
241 /* FIXME - support more formats */ |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
242 switch (fmt) { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
243 case IMGFMT_YV12: |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
244 case IMGFMT_IYUV: |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
245 case IMGFMT_I420: |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
246 return vf_next_query_format(vf, fmt); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
247 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
248 return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
249 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
250 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
251 static int config(struct vf_instance_s* vf, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
252 int width, int height, int d_width, int d_height, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
253 unsigned int flags, unsigned int outfmt) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
254 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
255 if (height&3) return 0; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
256 return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
257 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
258 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
259 static void uninit(struct vf_instance_s* vf) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
260 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
261 pullup_free_context(vf->priv->ctx); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
262 free(vf->priv); |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
263 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
264 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
265 static int open(vf_instance_t *vf, char* args) |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
266 { |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
267 struct vf_priv_s *p; |
12549 | 268 struct pullup_context *c; |
14970
5d566b4628d0
direct rendering support drastically improves speed, but it's buggy. :( disabled for now...
rfelker
parents:
14954
diff
changeset
|
269 //vf->get_image = get_image; |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
270 vf->put_image = put_image; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
271 vf->config = config; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
272 vf->query_format = query_format; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
273 vf->uninit = uninit; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
274 vf->default_reqs = VFCAP_ACCEPT_STRIDE; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
275 vf->priv = p = calloc(1, sizeof(struct vf_priv_s)); |
12549 | 276 p->ctx = c = pullup_alloc_context(); |
14973 | 277 p->fakecount = 1; |
15037
dde2f0454527
1l! mplayer's verbose variable is not a flag but a signed number
rfelker
parents:
14973
diff
changeset
|
278 c->verbose = verbose>0; |
12549 | 279 c->junk_left = c->junk_right = 1; |
280 c->junk_top = c->junk_bottom = 4; | |
281 c->strict_breaks = 0; | |
13267 | 282 c->metric_plane = 0; |
12549 | 283 if (args) { |
13267 | 284 sscanf(args, "%d:%d:%d:%d:%d:%d", &c->junk_left, &c->junk_right, &c->junk_top, &c->junk_bottom, &c->strict_breaks, &c->metric_plane); |
12549 | 285 } |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
286 return 1; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
287 } |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
288 |
25960 | 289 const vf_info_t vf_info_pullup = { |
10664
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
290 "pullup (from field sequence to frames)", |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
291 "pullup", |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
292 "Rich Felker", |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
293 "", |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
294 open, |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
295 NULL |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
296 }; |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
297 |
d47ca466c97b
pullup -- third generation inverse telecine engine. the backend
rfelker
parents:
diff
changeset
|
298 |