* qatar/master:
vorbis: Validate that the floor 1 X values contain no duplicates.
avprobe: Identify codec probe failures rather than calling them unsupported codecs.
avformat: Probe codecs at score 0 on buffer exhaustion conditions.
avformat: Factorize codec probing.
Indeo Audio decoder
imc: make IMDCT support stereo output
imc: move channel-specific data into separate context
lavfi: remove request/poll and drawing functions from public API on next bump
lavfi: make avfilter_insert_pad and pals private on next bump.
lavfi: make formats API private on next bump.
avplay: use buffersrc instead of custom input filter.
avtools: move buffer management code from avconv to cmdutils.
avconv: don't use InputStream in the buffer management code.
avconv: fix exiting when max frames is reached.
mpc8: fix maximum bands handling
aacdec: Turn PS off when switching to stereo and turn it to implicit when switching to mono.
Conflicts:
Changelog
cmdutils.h
ffmpeg.c
ffplay.c
ffprobe.c
libavcodec/avcodec.h
libavcodec/mpc8.c
libavcodec/v210dec.h
libavcodec/version.h
libavcodec/vorbisdec.c
libavfilter/avfilter.c
libavfilter/avfilter.h
libavfilter/buffersrc.c
libavfilter/formats.c
libavfilter/src_movie.c
libavfilter/vf_aspect.c
libavfilter/vf_blackframe.c
libavfilter/vf_boxblur.c
libavfilter/vf_crop.c
libavfilter/vf_cropdetect.c
libavfilter/vf_delogo.c
libavfilter/vf_drawbox.c
libavfilter/vf_drawtext.c
libavfilter/vf_fade.c
libavfilter/vf_fifo.c
libavfilter/vf_format.c
libavfilter/vf_frei0r.c
libavfilter/vf_gradfun.c
libavfilter/vf_hflip.c
libavfilter/vf_hqdn3d.c
libavfilter/vf_libopencv.c
libavfilter/vf_lut.c
libavfilter/vf_overlay.c
libavfilter/vf_pad.c
libavfilter/vf_scale.c
libavfilter/vf_select.c
libavfilter/vf_showinfo.c
libavfilter/vf_transpose.c
libavfilter/vf_unsharp.c
libavfilter/vf_yadif.c
libavfilter/vsrc_color.c
libavfilter/vsrc_testsrc.c
libavformat/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -41,6 +41,7 @@ |
41 | 41 |
#include "libavutil/avassert.h" |
42 | 42 |
#include "libavutil/avstring.h" |
43 | 43 |
#include "libavutil/mathematics.h" |
44 |
+#include "libavutil/imgutils.h" |
|
44 | 45 |
#include "libavutil/parseutils.h" |
45 | 46 |
#include "libavutil/pixdesc.h" |
46 | 47 |
#include "libavutil/eval.h" |
... | ... |
@@ -1222,3 +1223,144 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) |
1222 | 1222 |
} |
1223 | 1223 |
return array; |
1224 | 1224 |
} |
1225 |
+ |
|
1226 |
+static int alloc_buffer(FrameBuffer **pool, AVCodecContext *s, FrameBuffer **pbuf) |
|
1227 |
+{ |
|
1228 |
+ FrameBuffer *buf = av_mallocz(sizeof(*buf)); |
|
1229 |
+ int i, ret; |
|
1230 |
+ const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; |
|
1231 |
+ int h_chroma_shift, v_chroma_shift; |
|
1232 |
+ int edge = 32; // XXX should be avcodec_get_edge_width(), but that fails on svq1 |
|
1233 |
+ int w = s->width, h = s->height; |
|
1234 |
+ |
|
1235 |
+ if (!buf) |
|
1236 |
+ return AVERROR(ENOMEM); |
|
1237 |
+ |
|
1238 |
+ avcodec_align_dimensions(s, &w, &h); |
|
1239 |
+ |
|
1240 |
+ if (!(s->flags & CODEC_FLAG_EMU_EDGE)) { |
|
1241 |
+ w += 2*edge; |
|
1242 |
+ h += 2*edge; |
|
1243 |
+ } |
|
1244 |
+ |
|
1245 |
+ if ((ret = av_image_alloc(buf->base, buf->linesize, w, h, |
|
1246 |
+ s->pix_fmt, 32)) < 0) { |
|
1247 |
+ av_freep(&buf); |
|
1248 |
+ return ret; |
|
1249 |
+ } |
|
1250 |
+ /* XXX this shouldn't be needed, but some tests break without this line |
|
1251 |
+ * those decoders are buggy and need to be fixed. |
|
1252 |
+ * the following tests fail: |
|
1253 |
+ * cdgraphics, ansi, aasc, fraps-v1, qtrle-1bit |
|
1254 |
+ */ |
|
1255 |
+ memset(buf->base[0], 128, ret); |
|
1256 |
+ |
|
1257 |
+ avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); |
|
1258 |
+ for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { |
|
1259 |
+ const int h_shift = i==0 ? 0 : h_chroma_shift; |
|
1260 |
+ const int v_shift = i==0 ? 0 : v_chroma_shift; |
|
1261 |
+ if ((s->flags & CODEC_FLAG_EMU_EDGE) || !buf->linesize[1] || !buf->base[i]) |
|
1262 |
+ buf->data[i] = buf->base[i]; |
|
1263 |
+ else |
|
1264 |
+ buf->data[i] = buf->base[i] + |
|
1265 |
+ FFALIGN((buf->linesize[i]*edge >> v_shift) + |
|
1266 |
+ (pixel_size*edge >> h_shift), 32); |
|
1267 |
+ } |
|
1268 |
+ buf->w = s->width; |
|
1269 |
+ buf->h = s->height; |
|
1270 |
+ buf->pix_fmt = s->pix_fmt; |
|
1271 |
+ buf->pool = pool; |
|
1272 |
+ |
|
1273 |
+ *pbuf = buf; |
|
1274 |
+ return 0; |
|
1275 |
+} |
|
1276 |
+ |
|
1277 |
+int codec_get_buffer(AVCodecContext *s, AVFrame *frame) |
|
1278 |
+{ |
|
1279 |
+ FrameBuffer **pool = s->opaque; |
|
1280 |
+ FrameBuffer *buf; |
|
1281 |
+ int ret, i; |
|
1282 |
+ |
|
1283 |
+ if(av_image_check_size(s->width, s->height, 0, s) || s->pix_fmt<0) |
|
1284 |
+ return -1; |
|
1285 |
+ |
|
1286 |
+ if (!*pool && (ret = alloc_buffer(pool, s, pool)) < 0) |
|
1287 |
+ return ret; |
|
1288 |
+ |
|
1289 |
+ buf = *pool; |
|
1290 |
+ *pool = buf->next; |
|
1291 |
+ buf->next = NULL; |
|
1292 |
+ if (buf->w != s->width || buf->h != s->height || buf->pix_fmt != s->pix_fmt) { |
|
1293 |
+ av_freep(&buf->base[0]); |
|
1294 |
+ av_free(buf); |
|
1295 |
+ if ((ret = alloc_buffer(pool, s, &buf)) < 0) |
|
1296 |
+ return ret; |
|
1297 |
+ } |
|
1298 |
+ av_assert0(!buf->refcount); |
|
1299 |
+ buf->refcount++; |
|
1300 |
+ |
|
1301 |
+ frame->opaque = buf; |
|
1302 |
+ frame->type = FF_BUFFER_TYPE_USER; |
|
1303 |
+ frame->extended_data = frame->data; |
|
1304 |
+ frame->pkt_pts = s->pkt ? s->pkt->pts : AV_NOPTS_VALUE; |
|
1305 |
+ frame->width = buf->w; |
|
1306 |
+ frame->height = buf->h; |
|
1307 |
+ frame->format = buf->pix_fmt; |
|
1308 |
+ frame->sample_aspect_ratio = s->sample_aspect_ratio; |
|
1309 |
+ |
|
1310 |
+ for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { |
|
1311 |
+ frame->base[i] = buf->base[i]; // XXX h264.c uses base though it shouldn't |
|
1312 |
+ frame->data[i] = buf->data[i]; |
|
1313 |
+ frame->linesize[i] = buf->linesize[i]; |
|
1314 |
+ } |
|
1315 |
+ |
|
1316 |
+ return 0; |
|
1317 |
+} |
|
1318 |
+ |
|
1319 |
+static void unref_buffer(FrameBuffer *buf) |
|
1320 |
+{ |
|
1321 |
+ FrameBuffer **pool = buf->pool; |
|
1322 |
+ |
|
1323 |
+ av_assert0(buf->refcount > 0); |
|
1324 |
+ buf->refcount--; |
|
1325 |
+ if (!buf->refcount) { |
|
1326 |
+ FrameBuffer *tmp; |
|
1327 |
+ for(tmp= *pool; tmp; tmp= tmp->next) |
|
1328 |
+ av_assert1(tmp != buf); |
|
1329 |
+ |
|
1330 |
+ buf->next = *pool; |
|
1331 |
+ *pool = buf; |
|
1332 |
+ } |
|
1333 |
+} |
|
1334 |
+ |
|
1335 |
+void codec_release_buffer(AVCodecContext *s, AVFrame *frame) |
|
1336 |
+{ |
|
1337 |
+ FrameBuffer *buf = frame->opaque; |
|
1338 |
+ int i; |
|
1339 |
+ |
|
1340 |
+ if(frame->type!=FF_BUFFER_TYPE_USER) |
|
1341 |
+ return avcodec_default_release_buffer(s, frame); |
|
1342 |
+ |
|
1343 |
+ for (i = 0; i < FF_ARRAY_ELEMS(frame->data); i++) |
|
1344 |
+ frame->data[i] = NULL; |
|
1345 |
+ |
|
1346 |
+ unref_buffer(buf); |
|
1347 |
+} |
|
1348 |
+ |
|
1349 |
+void filter_release_buffer(AVFilterBuffer *fb) |
|
1350 |
+{ |
|
1351 |
+ FrameBuffer *buf = fb->priv; |
|
1352 |
+ av_free(fb); |
|
1353 |
+ unref_buffer(buf); |
|
1354 |
+} |
|
1355 |
+ |
|
1356 |
+void free_buffer_pool(FrameBuffer **pool) |
|
1357 |
+{ |
|
1358 |
+ FrameBuffer *buf = *pool; |
|
1359 |
+ while (buf) { |
|
1360 |
+ *pool = buf->next; |
|
1361 |
+ av_freep(&buf->base[0]); |
|
1362 |
+ av_free(buf); |
|
1363 |
+ buf = *pool; |
|
1364 |
+ } |
|
1365 |
+} |
... | ... |
@@ -386,4 +386,46 @@ void exit_program(int ret); |
386 | 386 |
*/ |
387 | 387 |
void *grow_array(void *array, int elem_size, int *size, int new_size); |
388 | 388 |
|
389 |
+typedef struct FrameBuffer { |
|
390 |
+ uint8_t *base[4]; |
|
391 |
+ uint8_t *data[4]; |
|
392 |
+ int linesize[4]; |
|
393 |
+ |
|
394 |
+ int h, w; |
|
395 |
+ enum PixelFormat pix_fmt; |
|
396 |
+ |
|
397 |
+ int refcount; |
|
398 |
+ struct FrameBuffer **pool; ///< head of the buffer pool |
|
399 |
+ struct FrameBuffer *next; |
|
400 |
+} FrameBuffer; |
|
401 |
+ |
|
402 |
+/** |
|
403 |
+ * Get a frame from the pool. This is intended to be used as a callback for |
|
404 |
+ * AVCodecContext.get_buffer. |
|
405 |
+ * |
|
406 |
+ * @param s codec context. s->opaque must be a pointer to the head of the |
|
407 |
+ * buffer pool. |
|
408 |
+ * @param frame frame->opaque will be set to point to the FrameBuffer |
|
409 |
+ * containing the frame data. |
|
410 |
+ */ |
|
411 |
+int codec_get_buffer(AVCodecContext *s, AVFrame *frame); |
|
412 |
+ |
|
413 |
+/** |
|
414 |
+ * A callback to be used for AVCodecContext.release_buffer along with |
|
415 |
+ * codec_get_buffer(). |
|
416 |
+ */ |
|
417 |
+void codec_release_buffer(AVCodecContext *s, AVFrame *frame); |
|
418 |
+ |
|
419 |
+/** |
|
420 |
+ * A callback to be used for AVFilterBuffer.free. |
|
421 |
+ * @param fb buffer to free. fb->priv must be a pointer to the FrameBuffer |
|
422 |
+ * containing the buffer data. |
|
423 |
+ */ |
|
424 |
+void filter_release_buffer(AVFilterBuffer *fb); |
|
425 |
+ |
|
426 |
+/** |
|
427 |
+ * Free all the buffers in the pool. This must be called after all the |
|
428 |
+ * buffers have been released. |
|
429 |
+ */ |
|
430 |
+void free_buffer_pool(FrameBuffer **pool); |
|
389 | 431 |
#endif /* CMDUTILS_H */ |
... | ... |
@@ -748,6 +748,7 @@ following image formats are supported: |
748 | 748 |
@tab encoding supported through external library libgsm |
749 | 749 |
@item GSM Microsoft variant @tab E @tab X |
750 | 750 |
@tab encoding supported through external library libgsm |
751 |
+@item IAC (Indeo Audio Coder) @tab @tab X |
|
751 | 752 |
@item IMC (Intel Music Coder) @tab @tab X |
752 | 753 |
@item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X |
753 | 754 |
@item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X |
... | ... |
@@ -201,19 +201,6 @@ typedef struct FilterGraph { |
201 | 201 |
int nb_outputs; |
202 | 202 |
} FilterGraph; |
203 | 203 |
|
204 |
-typedef struct FrameBuffer { |
|
205 |
- uint8_t *base[4]; |
|
206 |
- uint8_t *data[4]; |
|
207 |
- int linesize[4]; |
|
208 |
- |
|
209 |
- int h, w; |
|
210 |
- enum PixelFormat pix_fmt; |
|
211 |
- |
|
212 |
- int refcount; |
|
213 |
- struct InputStream *ist; |
|
214 |
- struct FrameBuffer *next; |
|
215 |
-} FrameBuffer; |
|
216 |
- |
|
217 | 204 |
typedef struct InputStream { |
218 | 205 |
int file_index; |
219 | 206 |
AVStream *st; |
... | ... |
@@ -534,145 +521,6 @@ static void reset_options(OptionsContext *o, int is_input) |
534 | 534 |
init_opts(); |
535 | 535 |
} |
536 | 536 |
|
537 |
-static int alloc_buffer(InputStream *ist, AVCodecContext *s, FrameBuffer **pbuf) |
|
538 |
-{ |
|
539 |
- FrameBuffer *buf = av_mallocz(sizeof(*buf)); |
|
540 |
- int i, ret; |
|
541 |
- const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; |
|
542 |
- int h_chroma_shift, v_chroma_shift; |
|
543 |
- int edge = 32; // XXX should be avcodec_get_edge_width(), but that fails on svq1 |
|
544 |
- int w = s->width, h = s->height; |
|
545 |
- |
|
546 |
- if (!buf) |
|
547 |
- return AVERROR(ENOMEM); |
|
548 |
- |
|
549 |
- avcodec_align_dimensions(s, &w, &h); |
|
550 |
- |
|
551 |
- if (!(s->flags & CODEC_FLAG_EMU_EDGE)) { |
|
552 |
- w += 2*edge; |
|
553 |
- h += 2*edge; |
|
554 |
- } |
|
555 |
- |
|
556 |
- if ((ret = av_image_alloc(buf->base, buf->linesize, w, h, |
|
557 |
- s->pix_fmt, 32)) < 0) { |
|
558 |
- av_freep(&buf); |
|
559 |
- return ret; |
|
560 |
- } |
|
561 |
- /* XXX this shouldn't be needed, but some tests break without this line |
|
562 |
- * those decoders are buggy and need to be fixed. |
|
563 |
- * the following tests fail: |
|
564 |
- * cdgraphics, ansi, aasc, fraps-v1, qtrle-1bit |
|
565 |
- */ |
|
566 |
- memset(buf->base[0], 128, ret); |
|
567 |
- |
|
568 |
- avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); |
|
569 |
- for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { |
|
570 |
- const int h_shift = i==0 ? 0 : h_chroma_shift; |
|
571 |
- const int v_shift = i==0 ? 0 : v_chroma_shift; |
|
572 |
- if ((s->flags & CODEC_FLAG_EMU_EDGE) || !buf->linesize[1] || !buf->base[i]) |
|
573 |
- buf->data[i] = buf->base[i]; |
|
574 |
- else |
|
575 |
- buf->data[i] = buf->base[i] + |
|
576 |
- FFALIGN((buf->linesize[i]*edge >> v_shift) + |
|
577 |
- (pixel_size*edge >> h_shift), 32); |
|
578 |
- } |
|
579 |
- buf->w = s->width; |
|
580 |
- buf->h = s->height; |
|
581 |
- buf->pix_fmt = s->pix_fmt; |
|
582 |
- buf->ist = ist; |
|
583 |
- |
|
584 |
- *pbuf = buf; |
|
585 |
- return 0; |
|
586 |
-} |
|
587 |
- |
|
588 |
-static void free_buffer_pool(InputStream *ist) |
|
589 |
-{ |
|
590 |
- FrameBuffer *buf = ist->buffer_pool; |
|
591 |
- while (buf) { |
|
592 |
- ist->buffer_pool = buf->next; |
|
593 |
- av_freep(&buf->base[0]); |
|
594 |
- av_free(buf); |
|
595 |
- buf = ist->buffer_pool; |
|
596 |
- } |
|
597 |
-} |
|
598 |
- |
|
599 |
-static void unref_buffer(InputStream *ist, FrameBuffer *buf) |
|
600 |
-{ |
|
601 |
- av_assert0(buf->refcount > 0); |
|
602 |
- buf->refcount--; |
|
603 |
- if (!buf->refcount) { |
|
604 |
- FrameBuffer *tmp; |
|
605 |
- for(tmp= ist->buffer_pool; tmp; tmp= tmp->next) |
|
606 |
- av_assert1(tmp != buf); |
|
607 |
- buf->next = ist->buffer_pool; |
|
608 |
- ist->buffer_pool = buf; |
|
609 |
- } |
|
610 |
-} |
|
611 |
- |
|
612 |
-static int codec_get_buffer(AVCodecContext *s, AVFrame *frame) |
|
613 |
-{ |
|
614 |
- InputStream *ist = s->opaque; |
|
615 |
- FrameBuffer *buf; |
|
616 |
- int ret, i; |
|
617 |
- |
|
618 |
- if(av_image_check_size(s->width, s->height, 0, s) || s->pix_fmt<0) |
|
619 |
- return -1; |
|
620 |
- |
|
621 |
- if (!ist->buffer_pool && (ret = alloc_buffer(ist, s, &ist->buffer_pool)) < 0) |
|
622 |
- return ret; |
|
623 |
- |
|
624 |
- buf = ist->buffer_pool; |
|
625 |
- ist->buffer_pool = buf->next; |
|
626 |
- buf->next = NULL; |
|
627 |
- if (buf->w != s->width || buf->h != s->height || buf->pix_fmt != s->pix_fmt) { |
|
628 |
- av_freep(&buf->base[0]); |
|
629 |
- av_free(buf); |
|
630 |
- if ((ret = alloc_buffer(ist, s, &buf)) < 0) |
|
631 |
- return ret; |
|
632 |
- } |
|
633 |
- av_assert0(!buf->refcount); |
|
634 |
- buf->refcount++; |
|
635 |
- |
|
636 |
- frame->opaque = buf; |
|
637 |
- frame->type = FF_BUFFER_TYPE_USER; |
|
638 |
- frame->extended_data = frame->data; |
|
639 |
- frame->pkt_pts = s->pkt ? s->pkt->pts : AV_NOPTS_VALUE; |
|
640 |
- frame->width = buf->w; |
|
641 |
- frame->height = buf->h; |
|
642 |
- frame->format = buf->pix_fmt; |
|
643 |
- frame->sample_aspect_ratio = s->sample_aspect_ratio; |
|
644 |
- |
|
645 |
- for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { |
|
646 |
- frame->base[i] = buf->base[i]; // XXX h264.c uses base though it shouldn't |
|
647 |
- frame->data[i] = buf->data[i]; |
|
648 |
- frame->linesize[i] = buf->linesize[i]; |
|
649 |
- } |
|
650 |
- |
|
651 |
- return 0; |
|
652 |
-} |
|
653 |
- |
|
654 |
-static void codec_release_buffer(AVCodecContext *s, AVFrame *frame) |
|
655 |
-{ |
|
656 |
- InputStream *ist = s->opaque; |
|
657 |
- FrameBuffer *buf = frame->opaque; |
|
658 |
- int i; |
|
659 |
- |
|
660 |
- if(frame->type!=FF_BUFFER_TYPE_USER) |
|
661 |
- return avcodec_default_release_buffer(s, frame); |
|
662 |
- |
|
663 |
- for (i = 0; i < FF_ARRAY_ELEMS(frame->data); i++) |
|
664 |
- frame->data[i] = NULL; |
|
665 |
- |
|
666 |
- unref_buffer(ist, buf); |
|
667 |
-} |
|
668 |
- |
|
669 |
-static void filter_release_buffer(AVFilterBuffer *fb) |
|
670 |
-{ |
|
671 |
- FrameBuffer *buf = fb->priv; |
|
672 |
- av_free(fb); |
|
673 |
- unref_buffer(buf->ist, buf); |
|
674 |
-} |
|
675 |
- |
|
676 | 537 |
static enum PixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum PixelFormat target) |
677 | 538 |
{ |
678 | 539 |
if (codec && codec->pix_fmts) { |
... | ... |
@@ -1508,7 +1356,7 @@ void av_noreturn exit_program(int ret) |
1508 | 1508 |
for (i = 0; i < nb_input_streams; i++) { |
1509 | 1509 |
av_freep(&input_streams[i]->decoded_frame); |
1510 | 1510 |
av_dict_free(&input_streams[i]->opts); |
1511 |
- free_buffer_pool(input_streams[i]); |
|
1511 |
+ free_buffer_pool(&input_streams[i]->buffer_pool); |
|
1512 | 1512 |
av_freep(&input_streams[i]->filters); |
1513 | 1513 |
av_freep(&input_streams[i]); |
1514 | 1514 |
} |
... | ... |
@@ -2845,7 +2693,7 @@ static int init_input_stream(int ist_index, char *error, int error_len) |
2845 | 2845 |
if (codec->type == AVMEDIA_TYPE_VIDEO && ist->dr1) { |
2846 | 2846 |
ist->st->codec->get_buffer = codec_get_buffer; |
2847 | 2847 |
ist->st->codec->release_buffer = codec_release_buffer; |
2848 |
- ist->st->codec->opaque = ist; |
|
2848 |
+ ist->st->codec->opaque = &ist->buffer_pool; |
|
2849 | 2849 |
} |
2850 | 2850 |
|
2851 | 2851 |
if (!av_dict_get(ist->opts, "threads", NULL, 0)) |
... | ... |
@@ -49,6 +49,7 @@ |
49 | 49 |
# include "libavfilter/avfilter.h" |
50 | 50 |
# include "libavfilter/avfiltergraph.h" |
51 | 51 |
# include "libavfilter/buffersink.h" |
52 |
+# include "libavfilter/buffersrc.h" |
|
52 | 53 |
#endif |
53 | 54 |
|
54 | 55 |
#include <SDL.h> |
... | ... |
@@ -227,7 +228,10 @@ typedef struct VideoState { |
227 | 227 |
int step; |
228 | 228 |
|
229 | 229 |
#if CONFIG_AVFILTER |
230 |
+ AVFilterContext *in_video_filter; ///< the first filter in the video chain |
|
230 | 231 |
AVFilterContext *out_video_filter; ///< the last filter in the video chain |
232 |
+ int use_dr1; |
|
233 |
+ FrameBuffer *buffer_pool; |
|
231 | 234 |
#endif |
232 | 235 |
|
233 | 236 |
int refresh; |
... | ... |
@@ -1545,222 +1549,29 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke |
1545 | 1545 |
} |
1546 | 1546 |
|
1547 | 1547 |
#if CONFIG_AVFILTER |
1548 |
-typedef struct { |
|
1549 |
- VideoState *is; |
|
1550 |
- AVFrame *frame; |
|
1551 |
- int use_dr1; |
|
1552 |
-} FilterPriv; |
|
1553 |
- |
|
1554 |
-static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) |
|
1555 |
-{ |
|
1556 |
- AVFilterContext *ctx = codec->opaque; |
|
1557 |
- AVFilterBufferRef *ref; |
|
1558 |
- int perms = AV_PERM_WRITE; |
|
1559 |
- int i, w, h, stride[AV_NUM_DATA_POINTERS]; |
|
1560 |
- unsigned edge; |
|
1561 |
- int pixel_size; |
|
1562 |
- |
|
1563 |
- av_assert0(codec->flags & CODEC_FLAG_EMU_EDGE); |
|
1564 |
- |
|
1565 |
- if (codec->codec->capabilities & CODEC_CAP_NEG_LINESIZES) |
|
1566 |
- perms |= AV_PERM_NEG_LINESIZES; |
|
1567 |
- |
|
1568 |
- if (pic->buffer_hints & FF_BUFFER_HINTS_VALID) { |
|
1569 |
- if (pic->buffer_hints & FF_BUFFER_HINTS_READABLE) perms |= AV_PERM_READ; |
|
1570 |
- if (pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) perms |= AV_PERM_PRESERVE; |
|
1571 |
- if (pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE) perms |= AV_PERM_REUSE2; |
|
1572 |
- } |
|
1573 |
- if (pic->reference) perms |= AV_PERM_READ | AV_PERM_PRESERVE; |
|
1574 |
- |
|
1575 |
- w = codec->width; |
|
1576 |
- h = codec->height; |
|
1577 |
- |
|
1578 |
- if(av_image_check_size(w, h, 0, codec) || codec->pix_fmt<0) |
|
1579 |
- return -1; |
|
1580 |
- |
|
1581 |
- avcodec_align_dimensions2(codec, &w, &h, stride); |
|
1582 |
- edge = codec->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width(); |
|
1583 |
- w += edge << 1; |
|
1584 |
- h += edge << 1; |
|
1585 |
- if (codec->pix_fmt != ctx->outputs[0]->format) { |
|
1586 |
- av_log(codec, AV_LOG_ERROR, "Pixel format mismatches %d %d\n", codec->pix_fmt, ctx->outputs[0]->format); |
|
1587 |
- return -1; |
|
1588 |
- } |
|
1589 |
- if (!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h))) |
|
1590 |
- return -1; |
|
1591 |
- |
|
1592 |
- pixel_size = av_pix_fmt_descriptors[ref->format].comp[0].step_minus1 + 1; |
|
1593 |
- ref->video->w = codec->width; |
|
1594 |
- ref->video->h = codec->height; |
|
1595 |
- for (i = 0; i < 4; i ++) { |
|
1596 |
- unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0; |
|
1597 |
- unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0; |
|
1598 |
- |
|
1599 |
- pic->base[i] = ref->data[i]; |
|
1600 |
- if (ref->data[i]) { |
|
1601 |
- ref->data[i] += ((edge * pixel_size) >> hshift) + ((edge * ref->linesize[i]) >> vshift); |
|
1602 |
- } |
|
1603 |
- pic->data[i] = ref->data[i]; |
|
1604 |
- pic->linesize[i] = ref->linesize[i]; |
|
1605 |
- } |
|
1606 |
- pic->opaque = ref; |
|
1607 |
- pic->type = FF_BUFFER_TYPE_USER; |
|
1608 |
- pic->reordered_opaque = codec->reordered_opaque; |
|
1609 |
- pic->width = codec->width; |
|
1610 |
- pic->height = codec->height; |
|
1611 |
- pic->format = codec->pix_fmt; |
|
1612 |
- pic->sample_aspect_ratio = codec->sample_aspect_ratio; |
|
1613 |
- if (codec->pkt) pic->pkt_pts = codec->pkt->pts; |
|
1614 |
- else pic->pkt_pts = AV_NOPTS_VALUE; |
|
1615 |
- return 0; |
|
1616 |
-} |
|
1617 |
- |
|
1618 |
-static void input_release_buffer(AVCodecContext *codec, AVFrame *pic) |
|
1619 |
-{ |
|
1620 |
- memset(pic->data, 0, sizeof(pic->data)); |
|
1621 |
- avfilter_unref_buffer(pic->opaque); |
|
1622 |
-} |
|
1623 |
- |
|
1624 |
-static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic) |
|
1625 |
-{ |
|
1626 |
- AVFilterBufferRef *ref = pic->opaque; |
|
1627 |
- |
|
1628 |
- if (pic->data[0] == NULL) { |
|
1629 |
- pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; |
|
1630 |
- return codec->get_buffer(codec, pic); |
|
1631 |
- } |
|
1632 |
- |
|
1633 |
- if ((codec->width != ref->video->w) || (codec->height != ref->video->h) || |
|
1634 |
- (codec->pix_fmt != ref->format)) { |
|
1635 |
- av_log(codec, AV_LOG_ERROR, "Picture properties changed.\n"); |
|
1636 |
- return -1; |
|
1637 |
- } |
|
1638 |
- |
|
1639 |
- pic->reordered_opaque = codec->reordered_opaque; |
|
1640 |
- if (codec->pkt) pic->pkt_pts = codec->pkt->pts; |
|
1641 |
- else pic->pkt_pts = AV_NOPTS_VALUE; |
|
1642 |
- return 0; |
|
1643 |
-} |
|
1644 |
- |
|
1645 |
-static int input_init(AVFilterContext *ctx, const char *args, void *opaque) |
|
1646 |
-{ |
|
1647 |
- FilterPriv *priv = ctx->priv; |
|
1648 |
- AVCodecContext *codec; |
|
1649 |
- if (!opaque) return -1; |
|
1650 |
- |
|
1651 |
- priv->is = opaque; |
|
1652 |
- codec = priv->is->video_st->codec; |
|
1653 |
- codec->opaque = ctx; |
|
1654 |
- if (codec->codec->capabilities & CODEC_CAP_DR1) { |
|
1655 |
- av_assert0(codec->flags & CODEC_FLAG_EMU_EDGE); |
|
1656 |
- priv->use_dr1 = 1; |
|
1657 |
- codec->get_buffer = input_get_buffer; |
|
1658 |
- codec->release_buffer = input_release_buffer; |
|
1659 |
- codec->reget_buffer = input_reget_buffer; |
|
1660 |
- codec->thread_safe_callbacks = 1; |
|
1661 |
- } |
|
1662 |
- |
|
1663 |
- priv->frame = avcodec_alloc_frame(); |
|
1664 |
- |
|
1665 |
- return 0; |
|
1666 |
-} |
|
1667 |
- |
|
1668 |
-static void input_uninit(AVFilterContext *ctx) |
|
1669 |
-{ |
|
1670 |
- FilterPriv *priv = ctx->priv; |
|
1671 |
- av_free(priv->frame); |
|
1672 |
-} |
|
1673 |
- |
|
1674 |
-static int input_request_frame(AVFilterLink *link) |
|
1675 |
-{ |
|
1676 |
- FilterPriv *priv = link->src->priv; |
|
1677 |
- AVFilterBufferRef *picref; |
|
1678 |
- int64_t pts = 0; |
|
1679 |
- AVPacket pkt; |
|
1680 |
- int ret; |
|
1681 |
- |
|
1682 |
- while (!(ret = get_video_frame(priv->is, priv->frame, &pts, &pkt))) |
|
1683 |
- av_free_packet(&pkt); |
|
1684 |
- if (ret < 0) |
|
1685 |
- return -1; |
|
1686 |
- |
|
1687 |
- if (priv->use_dr1 && priv->frame->opaque) { |
|
1688 |
- picref = avfilter_ref_buffer(priv->frame->opaque, ~0); |
|
1689 |
- } else { |
|
1690 |
- picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, priv->frame->width, priv->frame->height); |
|
1691 |
- av_image_copy(picref->data, picref->linesize, |
|
1692 |
- (const uint8_t **)(void **)priv->frame->data, priv->frame->linesize, |
|
1693 |
- picref->format, priv->frame->width, priv->frame->height); |
|
1694 |
- } |
|
1695 |
- av_free_packet(&pkt); |
|
1696 |
- |
|
1697 |
- avfilter_copy_frame_props(picref, priv->frame); |
|
1698 |
- picref->video->sample_aspect_ratio = av_guess_sample_aspect_ratio(priv->is->ic, priv->is->video_st, priv->frame); |
|
1699 |
- picref->pts = pts; |
|
1700 |
- |
|
1701 |
- avfilter_start_frame(link, picref); |
|
1702 |
- avfilter_draw_slice(link, 0, picref->video->h, 1); |
|
1703 |
- avfilter_end_frame(link); |
|
1704 |
- |
|
1705 |
- return 0; |
|
1706 |
-} |
|
1707 |
- |
|
1708 |
-static int input_query_formats(AVFilterContext *ctx) |
|
1709 |
-{ |
|
1710 |
- FilterPriv *priv = ctx->priv; |
|
1711 |
- enum PixelFormat pix_fmts[] = { |
|
1712 |
- priv->is->video_st->codec->pix_fmt, PIX_FMT_NONE |
|
1713 |
- }; |
|
1714 |
- |
|
1715 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
1716 |
- return 0; |
|
1717 |
-} |
|
1718 |
- |
|
1719 |
-static int input_config_props(AVFilterLink *link) |
|
1720 |
-{ |
|
1721 |
- FilterPriv *priv = link->src->priv; |
|
1722 |
- AVStream *s = priv->is->video_st; |
|
1723 |
- |
|
1724 |
- link->w = s->codec->width; |
|
1725 |
- link->h = s->codec->height; |
|
1726 |
- link->sample_aspect_ratio = s->sample_aspect_ratio.num ? |
|
1727 |
- s->sample_aspect_ratio : s->codec->sample_aspect_ratio; |
|
1728 |
- link->time_base = s->time_base; |
|
1729 |
- |
|
1730 |
- return 0; |
|
1731 |
-} |
|
1732 |
- |
|
1733 |
-static AVFilter input_filter = |
|
1734 |
-{ |
|
1735 |
- .name = "ffplay_input", |
|
1736 |
- |
|
1737 |
- .priv_size = sizeof(FilterPriv), |
|
1738 |
- |
|
1739 |
- .init = input_init, |
|
1740 |
- .uninit = input_uninit, |
|
1741 |
- |
|
1742 |
- .query_formats = input_query_formats, |
|
1743 |
- |
|
1744 |
- .inputs = (AVFilterPad[]) {{ .name = NULL }}, |
|
1745 |
- .outputs = (AVFilterPad[]) {{ .name = "default", |
|
1746 |
- .type = AVMEDIA_TYPE_VIDEO, |
|
1747 |
- .request_frame = input_request_frame, |
|
1748 |
- .config_props = input_config_props, }, |
|
1749 |
- { .name = NULL }}, |
|
1750 |
-}; |
|
1751 |
- |
|
1752 | 1548 |
static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters) |
1753 | 1549 |
{ |
1754 | 1550 |
static const enum PixelFormat pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE }; |
1755 | 1551 |
char sws_flags_str[128]; |
1552 |
+ char buffersrc_args[256]; |
|
1756 | 1553 |
int ret; |
1757 | 1554 |
AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc(); |
1758 |
- AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format;; |
|
1555 |
+ AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format; |
|
1556 |
+ AVCodecContext *codec = is->video_st->codec; |
|
1557 |
+ |
|
1759 | 1558 |
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags); |
1760 | 1559 |
graph->scale_sws_opts = av_strdup(sws_flags_str); |
1761 | 1560 |
|
1762 |
- if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src", |
|
1763 |
- NULL, is, graph)) < 0) |
|
1561 |
+ snprintf(buffersrc_args, sizeof(buffersrc_args), "%d:%d:%d:%d:%d:%d:%d", |
|
1562 |
+ codec->width, codec->height, codec->pix_fmt, |
|
1563 |
+ is->video_st->time_base.num, is->video_st->time_base.den, |
|
1564 |
+ codec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den); |
|
1565 |
+ |
|
1566 |
+ |
|
1567 |
+ if ((ret = avfilter_graph_create_filter(&filt_src, |
|
1568 |
+ avfilter_get_by_name("buffer"), |
|
1569 |
+ "src", buffersrc_args, NULL, |
|
1570 |
+ graph)) < 0) |
|
1764 | 1571 |
return ret; |
1765 | 1572 |
|
1766 | 1573 |
#if FF_API_OLD_VSINK_API |
... | ... |
@@ -1809,8 +1620,16 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c |
1809 | 1809 |
if ((ret = avfilter_graph_config(graph, NULL)) < 0) |
1810 | 1810 |
return ret; |
1811 | 1811 |
|
1812 |
+ is->in_video_filter = filt_src; |
|
1812 | 1813 |
is->out_video_filter = filt_out; |
1813 | 1814 |
|
1815 |
+ if (codec->codec->capabilities & CODEC_CAP_DR1) { |
|
1816 |
+ is->use_dr1 = 1; |
|
1817 |
+ codec->get_buffer = codec_get_buffer; |
|
1818 |
+ codec->release_buffer = codec_release_buffer; |
|
1819 |
+ codec->opaque = &is->buffer_pool; |
|
1820 |
+ } |
|
1821 |
+ |
|
1814 | 1822 |
return ret; |
1815 | 1823 |
} |
1816 | 1824 |
|
... | ... |
@@ -1826,7 +1645,7 @@ static int video_thread(void *arg) |
1826 | 1826 |
|
1827 | 1827 |
#if CONFIG_AVFILTER |
1828 | 1828 |
AVFilterGraph *graph = avfilter_graph_alloc(); |
1829 |
- AVFilterContext *filt_out = NULL; |
|
1829 |
+ AVFilterContext *filt_out = NULL, *filt_in = NULL; |
|
1830 | 1830 |
int last_w = is->video_st->codec->width; |
1831 | 1831 |
int last_h = is->video_st->codec->height; |
1832 | 1832 |
|
... | ... |
@@ -1837,18 +1656,31 @@ static int video_thread(void *arg) |
1837 | 1837 |
SDL_PushEvent(&event); |
1838 | 1838 |
goto the_end; |
1839 | 1839 |
} |
1840 |
+ filt_in = is->in_video_filter; |
|
1840 | 1841 |
filt_out = is->out_video_filter; |
1841 | 1842 |
#endif |
1842 | 1843 |
|
1843 | 1844 |
for (;;) { |
1844 |
-#if !CONFIG_AVFILTER |
|
1845 | 1845 |
AVPacket pkt; |
1846 |
-#else |
|
1846 |
+#if CONFIG_AVFILTER |
|
1847 | 1847 |
AVFilterBufferRef *picref; |
1848 | 1848 |
AVRational tb = filt_out->inputs[0]->time_base; |
1849 | 1849 |
#endif |
1850 | 1850 |
while (is->paused && !is->videoq.abort_request) |
1851 | 1851 |
SDL_Delay(10); |
1852 |
+ |
|
1853 |
+ ret = get_video_frame(is, frame, &pts_int, &pkt); |
|
1854 |
+ if (ret < 0) |
|
1855 |
+ goto the_end; |
|
1856 |
+ av_free_packet(&pkt); |
|
1857 |
+ |
|
1858 |
+ if (!ret) |
|
1859 |
+ continue; |
|
1860 |
+ |
|
1861 |
+ is->frame_last_filter_delay = av_gettime() / 1000000.0 - is->frame_last_returned_time; |
|
1862 |
+ if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0) |
|
1863 |
+ is->frame_last_filter_delay = 0; |
|
1864 |
+ |
|
1852 | 1865 |
#if CONFIG_AVFILTER |
1853 | 1866 |
if ( last_w != is->video_st->codec->width |
1854 | 1867 |
|| last_h != is->video_st->codec->height) { |
... | ... |
@@ -1862,48 +1694,55 @@ static int video_thread(void *arg) |
1862 | 1862 |
last_w = is->video_st->codec->width; |
1863 | 1863 |
last_h = is->video_st->codec->height; |
1864 | 1864 |
} |
1865 |
- ret = av_buffersink_get_buffer_ref(filt_out, &picref, 0); |
|
1866 |
- if (picref) { |
|
1865 |
+ |
|
1866 |
+ frame->pts = pts_int; |
|
1867 |
+ if (is->use_dr1) { |
|
1868 |
+ FrameBuffer *buf = frame->opaque; |
|
1869 |
+ AVFilterBufferRef *fb = avfilter_get_video_buffer_ref_from_arrays( |
|
1870 |
+ frame->data, frame->linesize, |
|
1871 |
+ AV_PERM_READ | AV_PERM_PRESERVE, |
|
1872 |
+ frame->width, frame->height, |
|
1873 |
+ frame->format); |
|
1874 |
+ |
|
1875 |
+ avfilter_copy_frame_props(fb, frame); |
|
1876 |
+ fb->buf->priv = buf; |
|
1877 |
+ fb->buf->free = filter_release_buffer; |
|
1878 |
+ |
|
1879 |
+ buf->refcount++; |
|
1880 |
+ av_buffersrc_buffer(filt_in, fb); |
|
1881 |
+ |
|
1882 |
+ } else |
|
1883 |
+ av_buffersrc_write_frame(filt_in, frame); |
|
1884 |
+ |
|
1885 |
+ while (ret >= 0) { |
|
1886 |
+ ret = av_buffersink_get_buffer_ref(filt_out, &picref, 0); |
|
1887 |
+ if (ret < 0) { |
|
1888 |
+ ret = 0; |
|
1889 |
+ break; |
|
1890 |
+ } |
|
1891 |
+ |
|
1867 | 1892 |
avfilter_fill_frame_from_video_buffer_ref(frame, picref); |
1893 |
+ |
|
1868 | 1894 |
pts_int = picref->pts; |
1869 | 1895 |
tb = filt_out->inputs[0]->time_base; |
1870 | 1896 |
pos = picref->pos; |
1871 | 1897 |
frame->opaque = picref; |
1872 | 1898 |
|
1873 |
- ret = 1; |
|
1874 |
- } |
|
1875 |
- |
|
1876 |
- if (ret >= 0 && av_cmp_q(tb, is->video_st->time_base)) { |
|
1877 |
- av_unused int64_t pts1 = pts_int; |
|
1878 |
- pts_int = av_rescale_q(pts_int, tb, is->video_st->time_base); |
|
1879 |
- av_dlog(NULL, "video_thread(): " |
|
1880 |
- "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n", |
|
1881 |
- tb.num, tb.den, pts1, |
|
1882 |
- is->video_st->time_base.num, is->video_st->time_base.den, pts_int); |
|
1899 |
+ if (av_cmp_q(tb, is->video_st->time_base)) { |
|
1900 |
+ av_unused int64_t pts1 = pts_int; |
|
1901 |
+ pts_int = av_rescale_q(pts_int, tb, is->video_st->time_base); |
|
1902 |
+ av_dlog(NULL, "video_thread(): " |
|
1903 |
+ "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n", |
|
1904 |
+ tb.num, tb.den, pts1, |
|
1905 |
+ is->video_st->time_base.num, is->video_st->time_base.den, pts_int); |
|
1906 |
+ } |
|
1907 |
+ pts = pts_int * av_q2d(is->video_st->time_base); |
|
1908 |
+ ret = queue_picture(is, frame, pts, pos); |
|
1883 | 1909 |
} |
1884 | 1910 |
#else |
1885 |
- ret = get_video_frame(is, frame, &pts_int, &pkt); |
|
1886 |
- pos = pkt.pos; |
|
1887 |
- av_free_packet(&pkt); |
|
1888 |
- if (ret == 0) |
|
1889 |
- continue; |
|
1890 |
-#endif |
|
1891 |
- |
|
1892 |
- if (ret < 0) |
|
1893 |
- goto the_end; |
|
1894 |
- |
|
1895 |
- is->frame_last_filter_delay = av_gettime() / 1000000.0 - is->frame_last_returned_time; |
|
1896 |
- if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0) |
|
1897 |
- is->frame_last_filter_delay = 0; |
|
1898 |
- |
|
1899 |
-#if CONFIG_AVFILTER |
|
1900 |
- if (!picref) |
|
1901 |
- continue; |
|
1902 |
-#endif |
|
1903 |
- |
|
1904 | 1911 |
pts = pts_int * av_q2d(is->video_st->time_base); |
1905 |
- |
|
1906 |
- ret = queue_picture(is, frame, pts, pos); |
|
1912 |
+ ret = queue_picture(is, frame, pts, pkt.pos); |
|
1913 |
+#endif |
|
1907 | 1914 |
|
1908 | 1915 |
if (ret < 0) |
1909 | 1916 |
goto the_end; |
... | ... |
@@ -2461,6 +2300,7 @@ static void stream_component_close(VideoState *is, int stream_index) |
2461 | 2461 |
|
2462 | 2462 |
ic->streams[stream_index]->discard = AVDISCARD_ALL; |
2463 | 2463 |
avcodec_close(avctx); |
2464 |
+ free_buffer_pool(&is->buffer_pool); |
|
2464 | 2465 |
switch (avctx->codec_type) { |
2465 | 2466 |
case AVMEDIA_TYPE_AUDIO: |
2466 | 2467 |
is->audio_st = NULL; |
... | ... |
@@ -1866,7 +1866,11 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) |
1866 | 1866 |
AVStream *stream = fmt_ctx->streams[i]; |
1867 | 1867 |
AVCodec *codec; |
1868 | 1868 |
|
1869 |
- if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) { |
|
1869 |
+ if (stream->codec->codec_id == CODEC_ID_PROBE) { |
|
1870 |
+ av_log(NULL, AV_LOG_ERROR, |
|
1871 |
+ "Failed to probe codec for input stream %d\n", |
|
1872 |
+ stream->index); |
|
1873 |
+ } else if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) { |
|
1870 | 1874 |
av_log(NULL, AV_LOG_ERROR, |
1871 | 1875 |
"Unsupported codec with id %d for input stream %d\n", |
1872 | 1876 |
stream->codec->codec_id, stream->index); |
... | ... |
@@ -220,6 +220,7 @@ OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o |
220 | 220 |
OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o |
221 | 221 |
OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o |
222 | 222 |
OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o |
223 |
+OBJS-$(CONFIG_IAC_DECODER) += imc.o |
|
223 | 224 |
OBJS-$(CONFIG_IDCIN_DECODER) += idcinvideo.o |
224 | 225 |
OBJS-$(CONFIG_IDF_DECODER) += bintext.o cga_data.o |
225 | 226 |
OBJS-$(CONFIG_IFF_BYTERUN1_DECODER) += iff.o |
... | ... |
@@ -487,6 +487,7 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id) |
487 | 487 |
return NULL; |
488 | 488 |
|
489 | 489 |
ac->oc[1].m4ac.chan_config = 2; |
490 |
+ ac->oc[1].m4ac.ps = 0; |
|
490 | 491 |
} |
491 | 492 |
// And vice-versa |
492 | 493 |
if (!ac->tags_mapped && type == TYPE_SCE && ac->oc[1].m4ac.chan_config == 2) { |
... | ... |
@@ -504,6 +505,8 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id) |
504 | 504 |
return NULL; |
505 | 505 |
|
506 | 506 |
ac->oc[1].m4ac.chan_config = 1; |
507 |
+ if (ac->oc[1].m4ac.sbr) |
|
508 |
+ ac->oc[1].m4ac.ps = -1; |
|
507 | 509 |
} |
508 | 510 |
// For indexed channel configurations map the channels solely based on position. |
509 | 511 |
switch (ac->oc[1].m4ac.chan_config) { |
... | ... |
@@ -286,6 +286,7 @@ void avcodec_register_all(void) |
286 | 286 |
REGISTER_DECODER (G729, g729); |
287 | 287 |
REGISTER_DECODER (GSM, gsm); |
288 | 288 |
REGISTER_DECODER (GSM_MS, gsm_ms); |
289 |
+ REGISTER_DECODER (IAC, iac); |
|
289 | 290 |
REGISTER_DECODER (IMC, imc); |
290 | 291 |
REGISTER_DECODER (MACE3, mace3); |
291 | 292 |
REGISTER_DECODER (MACE6, mace6); |
... | ... |
@@ -406,6 +406,7 @@ enum CodecID { |
406 | 406 |
CODEC_ID_8SVX_FIB, |
407 | 407 |
CODEC_ID_BMV_AUDIO, |
408 | 408 |
CODEC_ID_RALF, |
409 |
+ CODEC_ID_IAC, |
|
409 | 410 |
CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'), |
410 | 411 |
CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'), |
411 | 412 |
CODEC_ID_SONIC = MKBETAG('S','O','N','C'), |
... | ... |
@@ -49,9 +49,7 @@ |
49 | 49 |
#define BANDS 32 |
50 | 50 |
#define COEFFS 256 |
51 | 51 |
|
52 |
-typedef struct { |
|
53 |
- AVFrame frame; |
|
54 |
- |
|
52 |
+typedef struct IMCChannel { |
|
55 | 53 |
float old_floor[BANDS]; |
56 | 54 |
float flcoeffs1[BANDS]; |
57 | 55 |
float flcoeffs2[BANDS]; |
... | ... |
@@ -61,16 +59,6 @@ typedef struct { |
61 | 61 |
float flcoeffs6[BANDS]; |
62 | 62 |
float CWdecoded[COEFFS]; |
63 | 63 |
|
64 |
- /** MDCT tables */ |
|
65 |
- //@{ |
|
66 |
- float mdct_sine_window[COEFFS]; |
|
67 |
- float post_cos[COEFFS]; |
|
68 |
- float post_sin[COEFFS]; |
|
69 |
- float pre_coef1[COEFFS]; |
|
70 |
- float pre_coef2[COEFFS]; |
|
71 |
- float last_fft_im[COEFFS]; |
|
72 |
- //@} |
|
73 |
- |
|
74 | 64 |
int bandWidthT[BANDS]; ///< codewords per band |
75 | 65 |
int bitsBandT[BANDS]; ///< how many bits per codeword in band |
76 | 66 |
int CWlengthT[COEFFS]; ///< how many bits in each codeword |
... | ... |
@@ -82,15 +70,37 @@ typedef struct { |
82 | 82 |
int skipFlagCount[BANDS]; ///< skipped coeffients per band |
83 | 83 |
int skipFlags[COEFFS]; ///< skip coefficient decoding or not |
84 | 84 |
int codewords[COEFFS]; ///< raw codewords read from bitstream |
85 |
+ |
|
86 |
+ float last_fft_im[COEFFS]; |
|
87 |
+ |
|
88 |
+ int decoder_reset; |
|
89 |
+} IMCChannel; |
|
90 |
+ |
|
91 |
+typedef struct { |
|
92 |
+ AVFrame frame; |
|
93 |
+ |
|
94 |
+ IMCChannel chctx[2]; |
|
95 |
+ |
|
96 |
+ /** MDCT tables */ |
|
97 |
+ //@{ |
|
98 |
+ float mdct_sine_window[COEFFS]; |
|
99 |
+ float post_cos[COEFFS]; |
|
100 |
+ float post_sin[COEFFS]; |
|
101 |
+ float pre_coef1[COEFFS]; |
|
102 |
+ float pre_coef2[COEFFS]; |
|
103 |
+ //@} |
|
104 |
+ |
|
85 | 105 |
float sqrt_tab[30]; |
86 | 106 |
GetBitContext gb; |
87 |
- int decoder_reset; |
|
88 | 107 |
float one_div_log2; |
89 | 108 |
|
90 | 109 |
DSPContext dsp; |
91 | 110 |
FFTContext fft; |
92 | 111 |
DECLARE_ALIGNED(32, FFTComplex, samples)[COEFFS / 2]; |
93 | 112 |
float *out_samples; |
113 |
+ |
|
114 |
+ int8_t cyclTab[32], cyclTab2[32]; |
|
115 |
+ float weights1[31], weights2[31]; |
|
94 | 116 |
} IMCContext; |
95 | 117 |
|
96 | 118 |
static VLC huffman_vlc[4][4]; |
... | ... |
@@ -110,15 +120,21 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) |
110 | 110 |
IMCContext *q = avctx->priv_data; |
111 | 111 |
double r1, r2; |
112 | 112 |
|
113 |
- if (avctx->channels != 1) { |
|
113 |
+ if ((avctx->codec_id == CODEC_ID_IMC && avctx->channels != 1) |
|
114 |
+ || (avctx->codec_id == CODEC_ID_IAC && avctx->channels > 2)) { |
|
114 | 115 |
av_log_ask_for_sample(avctx, "Number of channels is not supported\n"); |
115 | 116 |
return AVERROR_PATCHWELCOME; |
116 | 117 |
} |
117 | 118 |
|
118 |
- q->decoder_reset = 1; |
|
119 |
+ for (j = 0; j < avctx->channels; j++) { |
|
120 |
+ q->chctx[j].decoder_reset = 1; |
|
119 | 121 |
|
120 |
- for (i = 0; i < BANDS; i++) |
|
121 |
- q->old_floor[i] = 1.0; |
|
122 |
+ for (i = 0; i < BANDS; i++) |
|
123 |
+ q->chctx[j].old_floor[i] = 1.0; |
|
124 |
+ |
|
125 |
+ for (i = 0; i < COEFFS / 2; i++) |
|
126 |
+ q->chctx[j].last_fft_im[i] = 0; |
|
127 |
+ } |
|
122 | 128 |
|
123 | 129 |
/* Build mdct window, a simple sine window normalized with sqrt(2) */ |
124 | 130 |
ff_sine_window_init(q->mdct_sine_window, COEFFS); |
... | ... |
@@ -138,8 +154,6 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) |
138 | 138 |
q->pre_coef1[i] = -(r1 + r2) * sqrt(2.0); |
139 | 139 |
q->pre_coef2[i] = (r1 - r2) * sqrt(2.0); |
140 | 140 |
} |
141 |
- |
|
142 |
- q->last_fft_im[i] = 0; |
|
143 | 141 |
} |
144 | 142 |
|
145 | 143 |
/* Generate a square root table */ |
... | ... |
@@ -159,13 +173,26 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) |
159 | 159 |
} |
160 | 160 |
q->one_div_log2 = 1 / log(2); |
161 | 161 |
|
162 |
+ memcpy(q->cyclTab, cyclTab, sizeof(cyclTab)); |
|
163 |
+ memcpy(q->cyclTab2, cyclTab2, sizeof(cyclTab2)); |
|
164 |
+ if (avctx->codec_id == CODEC_ID_IAC) { |
|
165 |
+ q->cyclTab[29] = 31; |
|
166 |
+ q->cyclTab2[31] = 28; |
|
167 |
+ memcpy(q->weights1, iac_weights1, sizeof(iac_weights1)); |
|
168 |
+ memcpy(q->weights2, iac_weights2, sizeof(iac_weights2)); |
|
169 |
+ } else { |
|
170 |
+ memcpy(q->weights1, imc_weights1, sizeof(imc_weights1)); |
|
171 |
+ memcpy(q->weights2, imc_weights2, sizeof(imc_weights2)); |
|
172 |
+ } |
|
173 |
+ |
|
162 | 174 |
if ((ret = ff_fft_init(&q->fft, 7, 1))) { |
163 | 175 |
av_log(avctx, AV_LOG_INFO, "FFT init failed\n"); |
164 | 176 |
return ret; |
165 | 177 |
} |
166 | 178 |
ff_dsputil_init(&q->dsp, avctx); |
167 |
- avctx->sample_fmt = AV_SAMPLE_FMT_FLT; |
|
168 |
- avctx->channel_layout = AV_CH_LAYOUT_MONO; |
|
179 |
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT; |
|
180 |
+ avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO |
|
181 |
+ : AV_CH_LAYOUT_STEREO; |
|
169 | 182 |
|
170 | 183 |
avcodec_get_frame_defaults(&q->frame); |
171 | 184 |
avctx->coded_frame = &q->frame; |
... | ... |
@@ -199,13 +226,13 @@ static void imc_calculate_coeffs(IMCContext *q, float *flcoeffs1, |
199 | 199 |
} |
200 | 200 |
|
201 | 201 |
for (i = 0; i < BANDS; i++) { |
202 |
- for (cnt2 = i; cnt2 < cyclTab[i]; cnt2++) |
|
202 |
+ for (cnt2 = i; cnt2 < q->cyclTab[i]; cnt2++) |
|
203 | 203 |
flcoeffs5[cnt2] = flcoeffs5[cnt2] + workT3[i]; |
204 | 204 |
workT2[cnt2 - 1] = workT2[cnt2 - 1] + workT3[i]; |
205 | 205 |
} |
206 | 206 |
|
207 | 207 |
for (i = 1; i < BANDS; i++) { |
208 |
- accum = (workT2[i - 1] + accum) * imc_weights1[i - 1]; |
|
208 |
+ accum = (workT2[i - 1] + accum) * q->weights1[i - 1]; |
|
209 | 209 |
flcoeffs5[i] += accum; |
210 | 210 |
} |
211 | 211 |
|
... | ... |
@@ -213,7 +240,7 @@ static void imc_calculate_coeffs(IMCContext *q, float *flcoeffs1, |
213 | 213 |
workT2[i] = 0.0; |
214 | 214 |
|
215 | 215 |
for (i = 0; i < BANDS; i++) { |
216 |
- for (cnt2 = i - 1; cnt2 > cyclTab2[i]; cnt2--) |
|
216 |
+ for (cnt2 = i - 1; cnt2 > q->cyclTab2[i]; cnt2--) |
|
217 | 217 |
flcoeffs5[cnt2] += workT3[i]; |
218 | 218 |
workT2[cnt2+1] += workT3[i]; |
219 | 219 |
} |
... | ... |
@@ -221,7 +248,7 @@ static void imc_calculate_coeffs(IMCContext *q, float *flcoeffs1, |
221 | 221 |
accum = 0.0; |
222 | 222 |
|
223 | 223 |
for (i = BANDS-2; i >= 0; i--) { |
224 |
- accum = (workT2[i+1] + accum) * imc_weights2[i]; |
|
224 |
+ accum = (workT2[i+1] + accum) * q->weights2[i]; |
|
225 | 225 |
flcoeffs5[i] += accum; |
226 | 226 |
// there is missing code here, but it seems to never be triggered |
227 | 227 |
} |
... | ... |
@@ -313,8 +340,8 @@ static void imc_decode_level_coefficients2(IMCContext *q, int *levlCoeffBuf, |
313 | 313 |
/** |
314 | 314 |
* Perform bit allocation depending on bits available |
315 | 315 |
*/ |
316 |
-static int bit_allocation(IMCContext *q, int stream_format_code, int freebits, |
|
317 |
- int flag) |
|
316 |
+static int bit_allocation(IMCContext *q, IMCChannel *chctx, |
|
317 |
+ int stream_format_code, int freebits, int flag) |
|
318 | 318 |
{ |
319 | 319 |
int i, j; |
320 | 320 |
const float limit = -1.e20; |
... | ... |
@@ -333,43 +360,43 @@ static int bit_allocation(IMCContext *q, int stream_format_code, int freebits, |
333 | 333 |
int found_indx = 0; |
334 | 334 |
|
335 | 335 |
for (i = 0; i < BANDS; i++) |
336 |
- highest = FFMAX(highest, q->flcoeffs1[i]); |
|
336 |
+ highest = FFMAX(highest, chctx->flcoeffs1[i]); |
|
337 | 337 |
|
338 | 338 |
for (i = 0; i < BANDS - 1; i++) |
339 |
- q->flcoeffs4[i] = q->flcoeffs3[i] - log(q->flcoeffs5[i]) / log(2); |
|
340 |
- q->flcoeffs4[BANDS - 1] = limit; |
|
339 |
+ chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log(chctx->flcoeffs5[i]) / log(2); |
|
340 |
+ chctx->flcoeffs4[BANDS - 1] = limit; |
|
341 | 341 |
|
342 | 342 |
highest = highest * 0.25; |
343 | 343 |
|
344 | 344 |
for (i = 0; i < BANDS; i++) { |
345 | 345 |
indx = -1; |
346 |
- if ((band_tab[i + 1] - band_tab[i]) == q->bandWidthT[i]) |
|
346 |
+ if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i]) |
|
347 | 347 |
indx = 0; |
348 | 348 |
|
349 |
- if ((band_tab[i + 1] - band_tab[i]) > q->bandWidthT[i]) |
|
349 |
+ if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i]) |
|
350 | 350 |
indx = 1; |
351 | 351 |
|
352 |
- if (((band_tab[i + 1] - band_tab[i]) / 2) >= q->bandWidthT[i]) |
|
352 |
+ if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i]) |
|
353 | 353 |
indx = 2; |
354 | 354 |
|
355 | 355 |
if (indx == -1) |
356 | 356 |
return AVERROR_INVALIDDATA; |
357 | 357 |
|
358 |
- q->flcoeffs4[i] += xTab[(indx * 2 + (q->flcoeffs1[i] < highest)) * 2 + flag]; |
|
358 |
+ chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag]; |
|
359 | 359 |
} |
360 | 360 |
|
361 | 361 |
if (stream_format_code & 0x2) { |
362 |
- q->flcoeffs4[0] = limit; |
|
363 |
- q->flcoeffs4[1] = limit; |
|
364 |
- q->flcoeffs4[2] = limit; |
|
365 |
- q->flcoeffs4[3] = limit; |
|
362 |
+ chctx->flcoeffs4[0] = limit; |
|
363 |
+ chctx->flcoeffs4[1] = limit; |
|
364 |
+ chctx->flcoeffs4[2] = limit; |
|
365 |
+ chctx->flcoeffs4[3] = limit; |
|
366 | 366 |
} |
367 | 367 |
|
368 | 368 |
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) { |
369 |
- iacc += q->bandWidthT[i]; |
|
370 |
- summa += q->bandWidthT[i] * q->flcoeffs4[i]; |
|
369 |
+ iacc += chctx->bandWidthT[i]; |
|
370 |
+ summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i]; |
|
371 | 371 |
} |
372 |
- q->bandWidthT[BANDS - 1] = 0; |
|
372 |
+ chctx->bandWidthT[BANDS - 1] = 0; |
|
373 | 373 |
summa = (summa * 0.5 - freebits) / iacc; |
374 | 374 |
|
375 | 375 |
|
... | ... |
@@ -382,13 +409,13 @@ static int bit_allocation(IMCContext *q, int stream_format_code, int freebits, |
382 | 382 |
iacc = 0; |
383 | 383 |
|
384 | 384 |
for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) { |
385 |
- cwlen = av_clipf(((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6); |
|
385 |
+ cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6); |
|
386 | 386 |
|
387 |
- q->bitsBandT[j] = cwlen; |
|
388 |
- summer += q->bandWidthT[j] * cwlen; |
|
387 |
+ chctx->bitsBandT[j] = cwlen; |
|
388 |
+ summer += chctx->bandWidthT[j] * cwlen; |
|
389 | 389 |
|
390 | 390 |
if (cwlen > 0) |
391 |
- iacc += q->bandWidthT[j]; |
|
391 |
+ iacc += chctx->bandWidthT[j]; |
|
392 | 392 |
} |
393 | 393 |
|
394 | 394 |
flg = t2; |
... | ... |
@@ -405,13 +432,13 @@ static int bit_allocation(IMCContext *q, int stream_format_code, int freebits, |
405 | 405 |
|
406 | 406 |
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) { |
407 | 407 |
for (j = band_tab[i]; j < band_tab[i + 1]; j++) |
408 |
- q->CWlengthT[j] = q->bitsBandT[i]; |
|
408 |
+ chctx->CWlengthT[j] = chctx->bitsBandT[i]; |
|
409 | 409 |
} |
410 | 410 |
|
411 | 411 |
if (freebits > summer) { |
412 | 412 |
for (i = 0; i < BANDS; i++) { |
413 |
- workT[i] = (q->bitsBandT[i] == 6) ? -1.e20 |
|
414 |
- : (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415); |
|
413 |
+ workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20 |
|
414 |
+ : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415); |
|
415 | 415 |
} |
416 | 416 |
|
417 | 417 |
highest = 0.0; |
... | ... |
@@ -432,11 +459,11 @@ static int bit_allocation(IMCContext *q, int stream_format_code, int freebits, |
432 | 432 |
|
433 | 433 |
if (highest > -1.e20) { |
434 | 434 |
workT[found_indx] -= 2.0; |
435 |
- if (++q->bitsBandT[found_indx] == 6) |
|
435 |
+ if (++chctx->bitsBandT[found_indx] == 6) |
|
436 | 436 |
workT[found_indx] = -1.e20; |
437 | 437 |
|
438 | 438 |
for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) { |
439 |
- q->CWlengthT[j]++; |
|
439 |
+ chctx->CWlengthT[j]++; |
|
440 | 440 |
summer++; |
441 | 441 |
} |
442 | 442 |
} |
... | ... |
@@ -444,7 +471,7 @@ static int bit_allocation(IMCContext *q, int stream_format_code, int freebits, |
444 | 444 |
} |
445 | 445 |
if (freebits < summer) { |
446 | 446 |
for (i = 0; i < BANDS; i++) { |
447 |
- workT[i] = q->bitsBandT[i] ? (q->bitsBandT[i] * -2 + q->flcoeffs4[i] + 1.585) |
|
447 |
+ workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585) |
|
448 | 448 |
: 1.e20; |
449 | 449 |
} |
450 | 450 |
if (stream_format_code & 0x2) { |
... | ... |
@@ -466,12 +493,12 @@ static int bit_allocation(IMCContext *q, int stream_format_code, int freebits, |
466 | 466 |
// break; |
467 | 467 |
workT[low_indx] = lowest + 2.0; |
468 | 468 |
|
469 |
- if (!--q->bitsBandT[low_indx]) |
|
469 |
+ if (!--chctx->bitsBandT[low_indx]) |
|
470 | 470 |
workT[low_indx] = 1.e20; |
471 | 471 |
|
472 | 472 |
for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) { |
473 |
- if (q->CWlengthT[j] > 0) { |
|
474 |
- q->CWlengthT[j]--; |
|
473 |
+ if (chctx->CWlengthT[j] > 0) { |
|
474 |
+ chctx->CWlengthT[j]--; |
|
475 | 475 |
summer--; |
476 | 476 |
} |
477 | 477 |
} |
... | ... |
@@ -480,54 +507,54 @@ static int bit_allocation(IMCContext *q, int stream_format_code, int freebits, |
480 | 480 |
return 0; |
481 | 481 |
} |
482 | 482 |
|
483 |
-static void imc_get_skip_coeff(IMCContext *q) |
|
483 |
+static void imc_get_skip_coeff(IMCContext *q, IMCChannel *chctx) |
|
484 | 484 |
{ |
485 | 485 |
int i, j; |
486 | 486 |
|
487 |
- memset(q->skipFlagBits, 0, sizeof(q->skipFlagBits)); |
|
488 |
- memset(q->skipFlagCount, 0, sizeof(q->skipFlagCount)); |
|
487 |
+ memset(chctx->skipFlagBits, 0, sizeof(chctx->skipFlagBits)); |
|
488 |
+ memset(chctx->skipFlagCount, 0, sizeof(chctx->skipFlagCount)); |
|
489 | 489 |
for (i = 0; i < BANDS; i++) { |
490 |
- if (!q->bandFlagsBuf[i] || !q->bandWidthT[i]) |
|
490 |
+ if (!chctx->bandFlagsBuf[i] || !chctx->bandWidthT[i]) |
|
491 | 491 |
continue; |
492 | 492 |
|
493 |
- if (!q->skipFlagRaw[i]) { |
|
494 |
- q->skipFlagBits[i] = band_tab[i + 1] - band_tab[i]; |
|
493 |
+ if (!chctx->skipFlagRaw[i]) { |
|
494 |
+ chctx->skipFlagBits[i] = band_tab[i + 1] - band_tab[i]; |
|
495 | 495 |
|
496 | 496 |
for (j = band_tab[i]; j < band_tab[i + 1]; j++) { |
497 |
- q->skipFlags[j] = get_bits1(&q->gb); |
|
498 |
- if (q->skipFlags[j]) |
|
499 |
- q->skipFlagCount[i]++; |
|
497 |
+ chctx->skipFlags[j] = get_bits1(&q->gb); |
|
498 |
+ if (chctx->skipFlags[j]) |
|
499 |
+ chctx->skipFlagCount[i]++; |
|
500 | 500 |
} |
501 | 501 |
} else { |
502 | 502 |
for (j = band_tab[i]; j < band_tab[i + 1] - 1; j += 2) { |
503 | 503 |
if (!get_bits1(&q->gb)) { // 0 |
504 |
- q->skipFlagBits[i]++; |
|
505 |
- q->skipFlags[j] = 1; |
|
506 |
- q->skipFlags[j + 1] = 1; |
|
507 |
- q->skipFlagCount[i] += 2; |
|
504 |
+ chctx->skipFlagBits[i]++; |
|
505 |
+ chctx->skipFlags[j] = 1; |
|
506 |
+ chctx->skipFlags[j + 1] = 1; |
|
507 |
+ chctx->skipFlagCount[i] += 2; |
|
508 | 508 |
} else { |
509 | 509 |
if (get_bits1(&q->gb)) { // 11 |
510 |
- q->skipFlagBits[i] += 2; |
|
511 |
- q->skipFlags[j] = 0; |
|
512 |
- q->skipFlags[j + 1] = 1; |
|
513 |
- q->skipFlagCount[i]++; |
|
510 |
+ chctx->skipFlagBits[i] += 2; |
|
511 |
+ chctx->skipFlags[j] = 0; |
|
512 |
+ chctx->skipFlags[j + 1] = 1; |
|
513 |
+ chctx->skipFlagCount[i]++; |
|
514 | 514 |
} else { |
515 |
- q->skipFlagBits[i] += 3; |
|
516 |
- q->skipFlags[j + 1] = 0; |
|
515 |
+ chctx->skipFlagBits[i] += 3; |
|
516 |
+ chctx->skipFlags[j + 1] = 0; |
|
517 | 517 |
if (!get_bits1(&q->gb)) { // 100 |
518 |
- q->skipFlags[j] = 1; |
|
519 |
- q->skipFlagCount[i]++; |
|
518 |
+ chctx->skipFlags[j] = 1; |
|
519 |
+ chctx->skipFlagCount[i]++; |
|
520 | 520 |
} else { // 101 |
521 |
- q->skipFlags[j] = 0; |
|
521 |
+ chctx->skipFlags[j] = 0; |
|
522 | 522 |
} |
523 | 523 |
} |
524 | 524 |
} |
525 | 525 |
} |
526 | 526 |
|
527 | 527 |
if (j < band_tab[i + 1]) { |
528 |
- q->skipFlagBits[i]++; |
|
529 |
- if ((q->skipFlags[j] = get_bits1(&q->gb))) |
|
530 |
- q->skipFlagCount[i]++; |
|
528 |
+ chctx->skipFlagBits[i]++; |
|
529 |
+ if ((chctx->skipFlags[j] = get_bits1(&q->gb))) |
|
530 |
+ chctx->skipFlagCount[i]++; |
|
531 | 531 |
} |
532 | 532 |
} |
533 | 533 |
} |
... | ... |
@@ -536,7 +563,8 @@ static void imc_get_skip_coeff(IMCContext *q) |
536 | 536 |
/** |
537 | 537 |
* Increase highest' band coefficient sizes as some bits won't be used |
538 | 538 |
*/ |
539 |
-static void imc_adjust_bit_allocation(IMCContext *q, int summer) |
|
539 |
+static void imc_adjust_bit_allocation(IMCContext *q, IMCChannel *chctx, |
|
540 |
+ int summer) |
|
540 | 541 |
{ |
541 | 542 |
float workT[32]; |
542 | 543 |
int corrected = 0; |
... | ... |
@@ -545,8 +573,8 @@ static void imc_adjust_bit_allocation(IMCContext *q, int summer) |
545 | 545 |
int found_indx = 0; |
546 | 546 |
|
547 | 547 |
for (i = 0; i < BANDS; i++) { |
548 |
- workT[i] = (q->bitsBandT[i] == 6) ? -1.e20 |
|
549 |
- : (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415); |
|
548 |
+ workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20 |
|
549 |
+ : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415); |
|
550 | 550 |
} |
551 | 551 |
|
552 | 552 |
while (corrected < summer) { |
... | ... |
@@ -564,12 +592,12 @@ static void imc_adjust_bit_allocation(IMCContext *q, int summer) |
564 | 564 |
|
565 | 565 |
if (highest > -1.e20) { |
566 | 566 |
workT[found_indx] -= 2.0; |
567 |
- if (++(q->bitsBandT[found_indx]) == 6) |
|
567 |
+ if (++(chctx->bitsBandT[found_indx]) == 6) |
|
568 | 568 |
workT[found_indx] = -1.e20; |
569 | 569 |
|
570 | 570 |
for (j = band_tab[found_indx]; j < band_tab[found_indx+1] && (corrected < summer); j++) { |
571 |
- if (!q->skipFlags[j] && (q->CWlengthT[j] < 6)) { |
|
572 |
- q->CWlengthT[j]++; |
|
571 |
+ if (!chctx->skipFlags[j] && (chctx->CWlengthT[j] < 6)) { |
|
572 |
+ chctx->CWlengthT[j]++; |
|
573 | 573 |
corrected++; |
574 | 574 |
} |
575 | 575 |
} |
... | ... |
@@ -577,17 +605,19 @@ static void imc_adjust_bit_allocation(IMCContext *q, int summer) |
577 | 577 |
} |
578 | 578 |
} |
579 | 579 |
|
580 |
-static void imc_imdct256(IMCContext *q) |
|
580 |
+static void imc_imdct256(IMCContext *q, IMCChannel *chctx, int channels) |
|
581 | 581 |
{ |
582 | 582 |
int i; |
583 | 583 |
float re, im; |
584 |
+ float *dst1 = q->out_samples; |
|
585 |
+ float *dst2 = q->out_samples + (COEFFS - 1) * channels; |
|
584 | 586 |
|
585 | 587 |
/* prerotation */ |
586 | 588 |
for (i = 0; i < COEFFS / 2; i++) { |
587 |
- q->samples[i].re = -(q->pre_coef1[i] * q->CWdecoded[COEFFS - 1 - i * 2]) - |
|
588 |
- (q->pre_coef2[i] * q->CWdecoded[i * 2]); |
|
589 |
- q->samples[i].im = (q->pre_coef2[i] * q->CWdecoded[COEFFS - 1 - i * 2]) - |
|
590 |
- (q->pre_coef1[i] * q->CWdecoded[i * 2]); |
|
589 |
+ q->samples[i].re = -(q->pre_coef1[i] * chctx->CWdecoded[COEFFS - 1 - i * 2]) - |
|
590 |
+ (q->pre_coef2[i] * chctx->CWdecoded[i * 2]); |
|
591 |
+ q->samples[i].im = (q->pre_coef2[i] * chctx->CWdecoded[COEFFS - 1 - i * 2]) - |
|
592 |
+ (q->pre_coef1[i] * chctx->CWdecoded[i * 2]); |
|
591 | 593 |
} |
592 | 594 |
|
593 | 595 |
/* FFT */ |
... | ... |
@@ -598,15 +628,18 @@ static void imc_imdct256(IMCContext *q) |
598 | 598 |
for (i = 0; i < COEFFS / 2; i++) { |
599 | 599 |
re = ( q->samples[i].re * q->post_cos[i]) + (-q->samples[i].im * q->post_sin[i]); |
600 | 600 |
im = (-q->samples[i].im * q->post_cos[i]) - ( q->samples[i].re * q->post_sin[i]); |
601 |
- q->out_samples[i * 2] = (q->mdct_sine_window[COEFFS - 1 - i * 2] * q->last_fft_im[i]) |
|
602 |
- + (q->mdct_sine_window[i * 2] * re); |
|
603 |
- q->out_samples[COEFFS - 1 - i * 2] = (q->mdct_sine_window[i * 2] * q->last_fft_im[i]) |
|
604 |
- - (q->mdct_sine_window[COEFFS - 1 - i * 2] * re); |
|
605 |
- q->last_fft_im[i] = im; |
|
601 |
+ *dst1 = (q->mdct_sine_window[COEFFS - 1 - i * 2] * chctx->last_fft_im[i]) |
|
602 |
+ + (q->mdct_sine_window[i * 2] * re); |
|
603 |
+ *dst2 = (q->mdct_sine_window[i * 2] * chctx->last_fft_im[i]) |
|
604 |
+ - (q->mdct_sine_window[COEFFS - 1 - i * 2] * re); |
|
605 |
+ dst1 += channels * 2; |
|
606 |
+ dst2 -= channels * 2; |
|
607 |
+ chctx->last_fft_im[i] = im; |
|
606 | 608 |
} |
607 | 609 |
} |
608 | 610 |
|
609 |
-static int inverse_quant_coeff(IMCContext *q, int stream_format_code) |
|
611 |
+static int inverse_quant_coeff(IMCContext *q, IMCChannel *chctx, |
|
612 |
+ int stream_format_code) |
|
610 | 613 |
{ |
611 | 614 |
int i, j; |
612 | 615 |
int middle_value, cw_len, max_size; |
... | ... |
@@ -614,30 +647,30 @@ static int inverse_quant_coeff(IMCContext *q, int stream_format_code) |
614 | 614 |
|
615 | 615 |
for (i = 0; i < BANDS; i++) { |
616 | 616 |
for (j = band_tab[i]; j < band_tab[i + 1]; j++) { |
617 |
- q->CWdecoded[j] = 0; |
|
618 |
- cw_len = q->CWlengthT[j]; |
|
617 |
+ chctx->CWdecoded[j] = 0; |
|
618 |
+ cw_len = chctx->CWlengthT[j]; |
|
619 | 619 |
|
620 |
- if (cw_len <= 0 || q->skipFlags[j]) |
|
620 |
+ if (cw_len <= 0 || chctx->skipFlags[j]) |
|
621 | 621 |
continue; |
622 | 622 |
|
623 | 623 |
max_size = 1 << cw_len; |
624 | 624 |
middle_value = max_size >> 1; |
625 | 625 |
|
626 |
- if (q->codewords[j] >= max_size || q->codewords[j] < 0) |
|
626 |
+ if (chctx->codewords[j] >= max_size || chctx->codewords[j] < 0) |
|
627 | 627 |
return AVERROR_INVALIDDATA; |
628 | 628 |
|
629 | 629 |
if (cw_len >= 4) { |
630 | 630 |
quantizer = imc_quantizer2[(stream_format_code & 2) >> 1]; |
631 |
- if (q->codewords[j] >= middle_value) |
|
632 |
- q->CWdecoded[j] = quantizer[q->codewords[j] - 8] * q->flcoeffs6[i]; |
|
631 |
+ if (chctx->codewords[j] >= middle_value) |
|
632 |
+ chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 8] * chctx->flcoeffs6[i]; |
|
633 | 633 |
else |
634 |
- q->CWdecoded[j] = -quantizer[max_size - q->codewords[j] - 8 - 1] * q->flcoeffs6[i]; |
|
634 |
+ chctx->CWdecoded[j] = -quantizer[max_size - chctx->codewords[j] - 8 - 1] * chctx->flcoeffs6[i]; |
|
635 | 635 |
}else{ |
636 |
- quantizer = imc_quantizer1[((stream_format_code & 2) >> 1) | (q->bandFlagsBuf[i] << 1)]; |
|
637 |
- if (q->codewords[j] >= middle_value) |
|
638 |
- q->CWdecoded[j] = quantizer[q->codewords[j] - 1] * q->flcoeffs6[i]; |
|
636 |
+ quantizer = imc_quantizer1[((stream_format_code & 2) >> 1) | (chctx->bandFlagsBuf[i] << 1)]; |
|
637 |
+ if (chctx->codewords[j] >= middle_value) |
|
638 |
+ chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 1] * chctx->flcoeffs6[i]; |
|
639 | 639 |
else |
640 |
- q->CWdecoded[j] = -quantizer[max_size - 2 - q->codewords[j]] * q->flcoeffs6[i]; |
|
640 |
+ chctx->CWdecoded[j] = -quantizer[max_size - 2 - chctx->codewords[j]] * chctx->flcoeffs6[i]; |
|
641 | 641 |
} |
642 | 642 |
} |
643 | 643 |
} |
... | ... |
@@ -645,16 +678,16 @@ static int inverse_quant_coeff(IMCContext *q, int stream_format_code) |
645 | 645 |
} |
646 | 646 |
|
647 | 647 |
|
648 |
-static int imc_get_coeffs(IMCContext *q) |
|
648 |
+static int imc_get_coeffs(IMCContext *q, IMCChannel *chctx) |
|
649 | 649 |
{ |
650 | 650 |
int i, j, cw_len, cw; |
651 | 651 |
|
652 | 652 |
for (i = 0; i < BANDS; i++) { |
653 |
- if (!q->sumLenArr[i]) |
|
653 |
+ if (!chctx->sumLenArr[i]) |
|
654 | 654 |
continue; |
655 |
- if (q->bandFlagsBuf[i] || q->bandWidthT[i]) { |
|
655 |
+ if (chctx->bandFlagsBuf[i] || chctx->bandWidthT[i]) { |
|
656 | 656 |
for (j = band_tab[i]; j < band_tab[i + 1]; j++) { |
657 |
- cw_len = q->CWlengthT[j]; |
|
657 |
+ cw_len = chctx->CWlengthT[j]; |
|
658 | 658 |
cw = 0; |
659 | 659 |
|
660 | 660 |
if (get_bits_count(&q->gb) + cw_len > 512) { |
... | ... |
@@ -662,149 +695,133 @@ static int imc_get_coeffs(IMCContext *q) |
662 | 662 |
return AVERROR_INVALIDDATA; |
663 | 663 |
} |
664 | 664 |
|
665 |
- if (cw_len && (!q->bandFlagsBuf[i] || !q->skipFlags[j])) |
|
665 |
+ if (cw_len && (!chctx->bandFlagsBuf[i] || !chctx->skipFlags[j])) |
|
666 | 666 |
cw = get_bits(&q->gb, cw_len); |
667 | 667 |
|
668 |
- q->codewords[j] = cw; |
|
668 |
+ chctx->codewords[j] = cw; |
|
669 | 669 |
} |
670 | 670 |
} |
671 | 671 |
} |
672 | 672 |
return 0; |
673 | 673 |
} |
674 | 674 |
|
675 |
-static int imc_decode_frame(AVCodecContext *avctx, void *data, |
|
676 |
- int *got_frame_ptr, AVPacket *avpkt) |
|
675 |
+static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch) |
|
677 | 676 |
{ |
678 |
- const uint8_t *buf = avpkt->data; |
|
679 |
- int buf_size = avpkt->size; |
|
680 |
- |
|
681 |
- IMCContext *q = avctx->priv_data; |
|
682 |
- |
|
683 | 677 |
int stream_format_code; |
684 | 678 |
int imc_hdr, i, j, ret; |
685 | 679 |
int flag; |
686 | 680 |
int bits, summer; |
687 | 681 |
int counter, bitscount; |
688 |
- LOCAL_ALIGNED_16(uint16_t, buf16, [IMC_BLOCK_SIZE / 2]); |
|
682 |
+ IMCChannel *chctx = q->chctx + ch; |
|
689 | 683 |
|
690 |
- if (buf_size < IMC_BLOCK_SIZE) { |
|
691 |
- av_log(avctx, AV_LOG_ERROR, "imc frame too small!\n"); |
|
692 |
- return AVERROR_INVALIDDATA; |
|
693 |
- } |
|
694 |
- |
|
695 |
- /* get output buffer */ |
|
696 |
- q->frame.nb_samples = COEFFS; |
|
697 |
- if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { |
|
698 |
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
699 |
- return ret; |
|
700 |
- } |
|
701 |
- q->out_samples = (float*)q->frame.data[0]; |
|
702 |
- |
|
703 |
- q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2); |
|
704 |
- |
|
705 |
- init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); |
|
706 | 684 |
|
707 | 685 |
/* Check the frame header */ |
708 | 686 |
imc_hdr = get_bits(&q->gb, 9); |
709 |
- if (imc_hdr != IMC_FRAME_ID) { |
|
710 |
- av_log(avctx, AV_LOG_ERROR, "imc frame header check failed!\n"); |
|
711 |
- av_log(avctx, AV_LOG_ERROR, "got %x instead of 0x21.\n", imc_hdr); |
|
687 |
+ if (imc_hdr & 0x18) { |
|
688 |
+ av_log(avctx, AV_LOG_ERROR, "frame header check failed!\n"); |
|
689 |
+ av_log(avctx, AV_LOG_ERROR, "got %X.\n", imc_hdr); |
|
712 | 690 |
return AVERROR_INVALIDDATA; |
713 | 691 |
} |
714 | 692 |
stream_format_code = get_bits(&q->gb, 3); |
715 | 693 |
|
716 | 694 |
if (stream_format_code & 1) { |
717 |
- av_log(avctx, AV_LOG_ERROR, "Stream code format %X is not supported\n", stream_format_code); |
|
718 |
- return AVERROR_INVALIDDATA; |
|
695 |
+ av_log_ask_for_sample(avctx, "Stream format %X is not supported\n", |
|
696 |
+ stream_format_code); |
|
697 |
+ return AVERROR_PATCHWELCOME; |
|
719 | 698 |
} |
720 | 699 |
|
721 | 700 |
// av_log(avctx, AV_LOG_DEBUG, "stream_format_code = %d\n", stream_format_code); |
722 | 701 |
|
723 | 702 |
if (stream_format_code & 0x04) |
724 |
- q->decoder_reset = 1; |
|
703 |
+ chctx->decoder_reset = 1; |
|
725 | 704 |
|
726 |
- if (q->decoder_reset) { |
|
705 |
+ if (chctx->decoder_reset) { |
|
727 | 706 |
memset(q->out_samples, 0, sizeof(q->out_samples)); |
728 | 707 |
for (i = 0; i < BANDS; i++) |
729 |
- q->old_floor[i] = 1.0; |
|
708 |
+ chctx->old_floor[i] = 1.0; |
|
730 | 709 |
for (i = 0; i < COEFFS; i++) |
731 |
- q->CWdecoded[i] = 0; |
|
732 |
- q->decoder_reset = 0; |
|
710 |
+ chctx->CWdecoded[i] = 0; |
|
711 |
+ chctx->decoder_reset = 0; |
|
733 | 712 |
} |
734 | 713 |
|
735 | 714 |
flag = get_bits1(&q->gb); |
736 |
- imc_read_level_coeffs(q, stream_format_code, q->levlCoeffBuf); |
|
715 |
+ imc_read_level_coeffs(q, stream_format_code, chctx->levlCoeffBuf); |
|
737 | 716 |
|
738 | 717 |
if (stream_format_code & 0x4) |
739 |
- imc_decode_level_coefficients(q, q->levlCoeffBuf, |
|
740 |
- q->flcoeffs1, q->flcoeffs2); |
|
718 |
+ imc_decode_level_coefficients(q, chctx->levlCoeffBuf, |
|
719 |
+ chctx->flcoeffs1, chctx->flcoeffs2); |
|
741 | 720 |
else |
742 |
- imc_decode_level_coefficients2(q, q->levlCoeffBuf, q->old_floor, |
|
743 |
- q->flcoeffs1, q->flcoeffs2); |
|
721 |
+ imc_decode_level_coefficients2(q, chctx->levlCoeffBuf, chctx->old_floor, |
|
722 |
+ chctx->flcoeffs1, chctx->flcoeffs2); |
|
744 | 723 |
|
745 |
- memcpy(q->old_floor, q->flcoeffs1, 32 * sizeof(float)); |
|
724 |
+ memcpy(chctx->old_floor, chctx->flcoeffs1, 32 * sizeof(float)); |
|
746 | 725 |
|
747 | 726 |
counter = 0; |
748 | 727 |
for (i = 0; i < BANDS; i++) { |
749 |
- if (q->levlCoeffBuf[i] == 16) { |
|
750 |
- q->bandWidthT[i] = 0; |
|
728 |
+ if (chctx->levlCoeffBuf[i] == 16) { |
|
729 |
+ chctx->bandWidthT[i] = 0; |
|
751 | 730 |
counter++; |
752 | 731 |
} else |
753 |
- q->bandWidthT[i] = band_tab[i + 1] - band_tab[i]; |
|
732 |
+ chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i]; |
|
754 | 733 |
} |
755 |
- memset(q->bandFlagsBuf, 0, BANDS * sizeof(int)); |
|
734 |
+ memset(chctx->bandFlagsBuf, 0, BANDS * sizeof(int)); |
|
756 | 735 |
for (i = 0; i < BANDS - 1; i++) { |
757 |
- if (q->bandWidthT[i]) |
|
758 |
- q->bandFlagsBuf[i] = get_bits1(&q->gb); |
|
736 |
+ if (chctx->bandWidthT[i]) |
|
737 |
+ chctx->bandFlagsBuf[i] = get_bits1(&q->gb); |
|
759 | 738 |
} |
760 | 739 |
|
761 |
- imc_calculate_coeffs(q, q->flcoeffs1, q->flcoeffs2, q->bandWidthT, q->flcoeffs3, q->flcoeffs5); |
|
740 |
+ imc_calculate_coeffs(q, chctx->flcoeffs1, chctx->flcoeffs2, chctx->bandWidthT, chctx->flcoeffs3, chctx->flcoeffs5); |
|
762 | 741 |
|
763 | 742 |
bitscount = 0; |
764 | 743 |
/* first 4 bands will be assigned 5 bits per coefficient */ |
765 | 744 |
if (stream_format_code & 0x2) { |
766 | 745 |
bitscount += 15; |
767 | 746 |
|
768 |
- q->bitsBandT[0] = 5; |
|
769 |
- q->CWlengthT[0] = 5; |
|
770 |
- q->CWlengthT[1] = 5; |
|
771 |
- q->CWlengthT[2] = 5; |
|
747 |
+ chctx->bitsBandT[0] = 5; |
|
748 |
+ chctx->CWlengthT[0] = 5; |
|
749 |
+ chctx->CWlengthT[1] = 5; |
|
750 |
+ chctx->CWlengthT[2] = 5; |
|
772 | 751 |
for (i = 1; i < 4; i++) { |
773 |
- bits = (q->levlCoeffBuf[i] == 16) ? 0 : 5; |
|
774 |
- q->bitsBandT[i] = bits; |
|
752 |
+ bits = (chctx->levlCoeffBuf[i] == 16) ? 0 : 5; |
|
753 |
+ chctx->bitsBandT[i] = bits; |
|
775 | 754 |
for (j = band_tab[i]; j < band_tab[i + 1]; j++) { |
776 |
- q->CWlengthT[j] = bits; |
|
755 |
+ chctx->CWlengthT[j] = bits; |
|
777 | 756 |
bitscount += bits; |
778 | 757 |
} |
779 | 758 |
} |
780 | 759 |
} |
760 |
+ if (avctx->codec_id == CODEC_ID_IAC) { |
|
761 |
+ bitscount += !!chctx->bandWidthT[BANDS - 1]; |
|
762 |
+ if (!(stream_format_code & 0x2)) |
|
763 |
+ bitscount += 16; |
|
764 |
+ } |
|
781 | 765 |
|
782 |
- if ((ret = bit_allocation(q, stream_format_code, |
|
766 |
+ if ((ret = bit_allocation(q, chctx, stream_format_code, |
|
783 | 767 |
512 - bitscount - get_bits_count(&q->gb), |
784 | 768 |
flag)) < 0) { |
785 | 769 |
av_log(avctx, AV_LOG_ERROR, "Bit allocations failed\n"); |
786 |
- q->decoder_reset = 1; |
|
770 |
+ chctx->decoder_reset = 1; |
|
787 | 771 |
return ret; |
788 | 772 |
} |
789 | 773 |
|
790 | 774 |
for (i = 0; i < BANDS; i++) { |
791 |
- q->sumLenArr[i] = 0; |
|
792 |
- q->skipFlagRaw[i] = 0; |
|
775 |
+ chctx->sumLenArr[i] = 0; |
|
776 |
+ chctx->skipFlagRaw[i] = 0; |
|
793 | 777 |
for (j = band_tab[i]; j < band_tab[i + 1]; j++) |
794 |
- q->sumLenArr[i] += q->CWlengthT[j]; |
|
795 |
- if (q->bandFlagsBuf[i]) |
|
796 |
- if ((((band_tab[i + 1] - band_tab[i]) * 1.5) > q->sumLenArr[i]) && (q->sumLenArr[i] > 0)) |
|
797 |
- q->skipFlagRaw[i] = 1; |
|
778 |
+ chctx->sumLenArr[i] += chctx->CWlengthT[j]; |
|
779 |
+ if (chctx->bandFlagsBuf[i]) |
|
780 |
+ if ((((band_tab[i + 1] - band_tab[i]) * 1.5) > chctx->sumLenArr[i]) && (chctx->sumLenArr[i] > 0)) |
|
781 |
+ chctx->skipFlagRaw[i] = 1; |
|
798 | 782 |
} |
799 | 783 |
|
800 |
- imc_get_skip_coeff(q); |
|
784 |
+ imc_get_skip_coeff(q, chctx); |
|
801 | 785 |
|
802 | 786 |
for (i = 0; i < BANDS; i++) { |
803 |
- q->flcoeffs6[i] = q->flcoeffs1[i]; |
|
787 |
+ chctx->flcoeffs6[i] = chctx->flcoeffs1[i]; |
|
804 | 788 |
/* band has flag set and at least one coded coefficient */ |
805 |
- if (q->bandFlagsBuf[i] && (band_tab[i + 1] - band_tab[i]) != q->skipFlagCount[i]) { |
|
806 |
- q->flcoeffs6[i] *= q->sqrt_tab[ band_tab[i + 1] - band_tab[i]] / |
|
807 |
- q->sqrt_tab[(band_tab[i + 1] - band_tab[i] - q->skipFlagCount[i])]; |
|
789 |
+ if (chctx->bandFlagsBuf[i] && (band_tab[i + 1] - band_tab[i]) != chctx->skipFlagCount[i]) { |
|
790 |
+ chctx->flcoeffs6[i] *= q->sqrt_tab[ band_tab[i + 1] - band_tab[i]] / |
|
791 |
+ q->sqrt_tab[(band_tab[i + 1] - band_tab[i] - chctx->skipFlagCount[i])]; |
|
808 | 792 |
} |
809 | 793 |
} |
810 | 794 |
|
... | ... |
@@ -812,49 +829,100 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, |
812 | 812 |
bits = summer = 0; |
813 | 813 |
|
814 | 814 |
for (i = 0; i < BANDS; i++) { |
815 |
- if (q->bandFlagsBuf[i]) { |
|
815 |
+ if (chctx->bandFlagsBuf[i]) { |
|
816 | 816 |
for (j = band_tab[i]; j < band_tab[i + 1]; j++) { |
817 |
- if (q->skipFlags[j]) { |
|
818 |
- summer += q->CWlengthT[j]; |
|
819 |
- q->CWlengthT[j] = 0; |
|
817 |
+ if (chctx->skipFlags[j]) { |
|
818 |
+ summer += chctx->CWlengthT[j]; |
|
819 |
+ chctx->CWlengthT[j] = 0; |
|
820 | 820 |
} |
821 | 821 |
} |
822 |
- bits += q->skipFlagBits[i]; |
|
823 |
- summer -= q->skipFlagBits[i]; |
|
822 |
+ bits += chctx->skipFlagBits[i]; |
|
823 |
+ summer -= chctx->skipFlagBits[i]; |
|
824 | 824 |
} |
825 | 825 |
} |
826 |
- imc_adjust_bit_allocation(q, summer); |
|
826 |
+ imc_adjust_bit_allocation(q, chctx, summer); |
|
827 | 827 |
|
828 | 828 |
for (i = 0; i < BANDS; i++) { |
829 |
- q->sumLenArr[i] = 0; |
|
829 |
+ chctx->sumLenArr[i] = 0; |
|
830 | 830 |
|
831 | 831 |
for (j = band_tab[i]; j < band_tab[i + 1]; j++) |
832 |
- if (!q->skipFlags[j]) |
|
833 |
- q->sumLenArr[i] += q->CWlengthT[j]; |
|
832 |
+ if (!chctx->skipFlags[j]) |
|
833 |
+ chctx->sumLenArr[i] += chctx->CWlengthT[j]; |
|
834 | 834 |
} |
835 | 835 |
|
836 |
- memset(q->codewords, 0, sizeof(q->codewords)); |
|
836 |
+ memset(chctx->codewords, 0, sizeof(chctx->codewords)); |
|
837 | 837 |
|
838 |
- if (imc_get_coeffs(q) < 0) { |
|
838 |
+ if (imc_get_coeffs(q, chctx) < 0) { |
|
839 | 839 |
av_log(avctx, AV_LOG_ERROR, "Read coefficients failed\n"); |
840 |
- q->decoder_reset = 1; |
|
840 |
+ chctx->decoder_reset = 1; |
|
841 | 841 |
return AVERROR_INVALIDDATA; |
842 | 842 |
} |
843 | 843 |
|
844 |
- if (inverse_quant_coeff(q, stream_format_code) < 0) { |
|
844 |
+ if (inverse_quant_coeff(q, chctx, stream_format_code) < 0) { |
|
845 | 845 |
av_log(avctx, AV_LOG_ERROR, "Inverse quantization of coefficients failed\n"); |
846 |
- q->decoder_reset = 1; |
|
846 |
+ chctx->decoder_reset = 1; |
|
847 | 847 |
return AVERROR_INVALIDDATA; |
848 | 848 |
} |
849 | 849 |
|
850 |
- memset(q->skipFlags, 0, sizeof(q->skipFlags)); |
|
850 |
+ memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags)); |
|
851 |
+ |
|
852 |
+ imc_imdct256(q, chctx, avctx->channels); |
|
853 |
+ |
|
854 |
+ return 0; |
|
855 |
+} |
|
856 |
+ |
|
857 |
+static int imc_decode_frame(AVCodecContext *avctx, void *data, |
|
858 |
+ int *got_frame_ptr, AVPacket *avpkt) |
|
859 |
+{ |
|
860 |
+ const uint8_t *buf = avpkt->data; |
|
861 |
+ int buf_size = avpkt->size; |
|
862 |
+ int ret, i; |
|
851 | 863 |
|
852 |
- imc_imdct256(q); |
|
864 |
+ IMCContext *q = avctx->priv_data; |
|
865 |
+ |
|
866 |
+ LOCAL_ALIGNED_16(uint16_t, buf16, [IMC_BLOCK_SIZE / 2]); |
|
867 |
+ |
|
868 |
+ if (buf_size < IMC_BLOCK_SIZE * avctx->channels) { |
|
869 |
+ av_log(avctx, AV_LOG_ERROR, "frame too small!\n"); |
|
870 |
+ return AVERROR_INVALIDDATA; |
|
871 |
+ } |
|
872 |
+ |
|
873 |
+ /* get output buffer */ |
|
874 |
+ q->frame.nb_samples = COEFFS; |
|
875 |
+ if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { |
|
876 |
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
877 |
+ return ret; |
|
878 |
+ } |
|
879 |
+ |
|
880 |
+ for (i = 0; i < avctx->channels; i++) { |
|
881 |
+ q->out_samples = (float*)q->frame.data[0] + i; |
|
882 |
+ |
|
883 |
+ q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2); |
|
884 |
+ |
|
885 |
+ init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); |
|
886 |
+ |
|
887 |
+ buf += IMC_BLOCK_SIZE; |
|
888 |
+ |
|
889 |
+ if ((ret = imc_decode_block(avctx, q, i)) < 0) |
|
890 |
+ return ret; |
|
891 |
+ } |
|
892 |
+ |
|
893 |
+ if (avctx->channels == 2) { |
|
894 |
+ float *src = (float*)q->frame.data[0], t1, t2; |
|
895 |
+ |
|
896 |
+ for (i = 0; i < COEFFS; i++) { |
|
897 |
+ t1 = src[0]; |
|
898 |
+ t2 = src[1]; |
|
899 |
+ src[0] = t1 + t2; |
|
900 |
+ src[1] = t1 - t2; |
|
901 |
+ src += 2; |
|
902 |
+ } |
|
903 |
+ } |
|
853 | 904 |
|
854 | 905 |
*got_frame_ptr = 1; |
855 | 906 |
*(AVFrame *)data = q->frame; |
856 | 907 |
|
857 |
- return IMC_BLOCK_SIZE; |
|
908 |
+ return IMC_BLOCK_SIZE * avctx->channels; |
|
858 | 909 |
} |
859 | 910 |
|
860 | 911 |
|
... | ... |
@@ -879,3 +947,15 @@ AVCodec ff_imc_decoder = { |
879 | 879 |
.capabilities = CODEC_CAP_DR1, |
880 | 880 |
.long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"), |
881 | 881 |
}; |
882 |
+ |
|
883 |
+AVCodec ff_iac_decoder = { |
|
884 |
+ .name = "iac", |
|
885 |
+ .type = AVMEDIA_TYPE_AUDIO, |
|
886 |
+ .id = CODEC_ID_IAC, |
|
887 |
+ .priv_data_size = sizeof(IMCContext), |
|
888 |
+ .init = imc_decode_init, |
|
889 |
+ .close = imc_decode_close, |
|
890 |
+ .decode = imc_decode_frame, |
|
891 |
+ .capabilities = CODEC_CAP_DR1, |
|
892 |
+ .long_name = NULL_IF_CONFIG_SMALL("IAC (Indeo Audio Coder)"), |
|
893 |
+}; |
... | ... |
@@ -44,6 +44,25 @@ static const int8_t cyclTab2[32] = { |
44 | 44 |
12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 21, 22, |
45 | 45 |
23, 24, 25, 26, 27, 28, 29}; |
46 | 46 |
|
47 |
+static const float iac_weights1[31] = { |
|
48 |
+ 0.0538585, 0.0576251, 0.0645592, 0.0494032, 0.0428915, 0.0592188, |
|
49 |
+ 0.0604145, 0.0673549, 0.0797351, 0.0972911, 0.119376, 0.144777, |
|
50 |
+ 0.17181, 0.198625, 0.242918, 0.262113, 0.278434, 0.310752, |
|
51 |
+ 0.319978, 0.328482, 0.354631, 0.380212, 0.388783, 0.400428, |
|
52 |
+ 0.43096, 0.462397, 0.479469, 0.499329, 0.534526, 0.568631, |
|
53 |
+ 0.589218 |
|
54 |
+}; |
|
55 |
+ |
|
56 |
+static const float iac_weights2[31] = { |
|
57 |
+ 0.000375307, 0.000450455, 0.000612191, 0.000297262, 0.000202956, |
|
58 |
+ 0.000484887, 0.000511777, 0.000686431, 0.00108256, 0.00185267, |
|
59 |
+ 0.00321869, 0.00541861, 0.00860266, 0.012726, 0.0219151, |
|
60 |
+ 0.0269104, 0.0316774, 0.0426107, 0.046113, 0.0494974, |
|
61 |
+ 0.0608692, 0.0734633, 0.0780208, 0.0844921, 0.103034, |
|
62 |
+ 0.124606, 0.137421, 0.153336, 0.184296, 0.217792, |
|
63 |
+ 0.239742 |
|
64 |
+}; |
|
65 |
+ |
|
47 | 66 |
static const float imc_weights1[31] = { |
48 | 67 |
0.119595, 0.123124, 0.129192, 9.97377e-2, 8.1923e-2, 9.61153e-2, 8.77885e-2, 8.61174e-2, |
49 | 68 |
9.00882e-2, 9.91658e-2, 0.112991, 0.131126, 0.152886, 0.177292, 0.221782, 0.244917, 0.267386, |
... | ... |
@@ -275,7 +275,8 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data, |
275 | 275 |
maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2); |
276 | 276 |
if(maxband > 32) maxband -= 33; |
277 | 277 |
} |
278 |
- if(maxband >= BANDS) { |
|
278 |
+ |
|
279 |
+ if(maxband > c->maxbands + 1 || maxband >= BANDS) { |
|
279 | 280 |
av_log(avctx, AV_LOG_ERROR, "maxband %d too large\n",maxband); |
280 | 281 |
return AVERROR_INVALIDDATA; |
281 | 282 |
} |
... | ... |
@@ -412,7 +413,8 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data, |
412 | 412 |
} |
413 | 413 |
} |
414 | 414 |
|
415 |
- ff_mpc_dequantize_and_synth(c, maxband, c->frame.data[0], avctx->channels); |
|
415 |
+ ff_mpc_dequantize_and_synth(c, maxband - 1, c->frame.data[0], |
|
416 |
+ avctx->channels); |
|
416 | 417 |
|
417 | 418 |
c->cur_frame++; |
418 | 419 |
|
... | ... |
@@ -123,7 +123,8 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) |
123 | 123 |
return 0; |
124 | 124 |
} |
125 | 125 |
|
126 |
-void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) |
|
126 |
+int ff_vorbis_ready_floor1_list(AVCodecContext *avccontext, |
|
127 |
+ vorbis_floor1_entry *list, int values) |
|
127 | 128 |
{ |
128 | 129 |
int i; |
129 | 130 |
list[0].sort = 0; |
... | ... |
@@ -147,6 +148,11 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) |
147 | 147 |
for (i = 0; i < values - 1; i++) { |
148 | 148 |
int j; |
149 | 149 |
for (j = i + 1; j < values; j++) { |
150 |
+ if (list[i].x == list[j].x) { |
|
151 |
+ av_log(avccontext, AV_LOG_ERROR, |
|
152 |
+ "Duplicate value found in floor 1 X coordinates\n"); |
|
153 |
+ return AVERROR_INVALIDDATA; |
|
154 |
+ } |
|
150 | 155 |
if (list[list[i].sort].x > list[list[j].sort].x) { |
151 | 156 |
int tmp = list[i].sort; |
152 | 157 |
list[i].sort = list[j].sort; |
... | ... |
@@ -154,6 +160,7 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) |
154 | 154 |
} |
155 | 155 |
} |
156 | 156 |
} |
157 |
+ return 0; |
|
157 | 158 |
} |
158 | 159 |
|
159 | 160 |
static inline void render_line_unrolled(intptr_t x, int y, int x1, |
... | ... |
@@ -36,7 +36,8 @@ typedef struct { |
36 | 36 |
uint16_t high; |
37 | 37 |
} vorbis_floor1_entry; |
38 | 38 |
|
39 |
-void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values); |
|
39 |
+int ff_vorbis_ready_floor1_list(AVCodecContext *avccontext, |
|
40 |
+ vorbis_floor1_entry *list, int values); |
|
40 | 41 |
unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n); // x^(1/n) |
41 | 42 |
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num); |
42 | 43 |
void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values, |
... | ... |
@@ -578,14 +578,10 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) |
578 | 578 |
} |
579 | 579 |
|
580 | 580 |
// Precalculate order of x coordinates - needed for decode |
581 |
- ff_vorbis_ready_floor1_list(floor_setup->data.t1.list, floor_setup->data.t1.x_list_dim); |
|
582 |
- |
|
583 |
- for (j=1; j<floor_setup->data.t1.x_list_dim; j++) { |
|
584 |
- if ( floor_setup->data.t1.list[ floor_setup->data.t1.list[j-1].sort ].x |
|
585 |
- == floor_setup->data.t1.list[ floor_setup->data.t1.list[j ].sort ].x) { |
|
586 |
- av_log(vc->avccontext, AV_LOG_ERROR, "Non unique x values in floor type 1\n"); |
|
587 |
- return AVERROR_INVALIDDATA; |
|
588 |
- } |
|
581 |
+ if (ff_vorbis_ready_floor1_list(vc->avccontext, |
|
582 |
+ floor_setup->data.t1.list, |
|
583 |
+ floor_setup->data.t1.x_list_dim)) { |
|
584 |
+ return AVERROR_INVALIDDATA; |
|
589 | 585 |
} |
590 | 586 |
} else if (floor_setup->floor_type == 0) { |
591 | 587 |
unsigned max_codebook_dim = 0; |
... | ... |
@@ -340,7 +340,8 @@ static int create_vorbis_context(vorbis_enc_context *venc, |
340 | 340 |
}; |
341 | 341 |
fc->list[i].x = a[i - 2]; |
342 | 342 |
} |
343 |
- ff_vorbis_ready_floor1_list(fc->list, fc->values); |
|
343 |
+ if (ff_vorbis_ready_floor1_list(avccontext, fc->list, fc->values)) |
|
344 |
+ return AVERROR_BUG; |
|
344 | 345 |
|
345 | 346 |
venc->nresidues = 1; |
346 | 347 |
venc->residues = av_malloc(sizeof(vorbis_enc_residue) * venc->nresidues); |
... | ... |
@@ -106,8 +106,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) |
106 | 106 |
} |
107 | 107 |
|
108 | 108 |
PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats, |
109 |
- avfilter_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); |
|
110 |
- PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, avfilter_add_format, |
|
109 |
+ ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); |
|
110 |
+ PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, |
|
111 | 111 |
get_sample_rate, 0, "sample rate"); |
112 | 112 |
PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts, |
113 | 113 |
ff_add_channel_layout, av_get_channel_layout, 0, |
... | ... |
@@ -122,8 +122,8 @@ static int query_formats(AVFilterContext *ctx) |
122 | 122 |
{ |
123 | 123 |
AFormatContext *s = ctx->priv; |
124 | 124 |
|
125 |
- avfilter_set_common_formats(ctx, s->formats ? s->formats : |
|
126 |
- avfilter_all_formats(AVMEDIA_TYPE_AUDIO)); |
|
125 |
+ ff_set_common_formats(ctx, s->formats ? s->formats : |
|
126 |
+ ff_all_formats(AVMEDIA_TYPE_AUDIO)); |
|
127 | 127 |
ff_set_common_samplerates(ctx, s->sample_rates ? s->sample_rates : |
128 | 128 |
ff_all_samplerates()); |
129 | 129 |
ff_set_common_channel_layouts(ctx, s->channel_layouts ? s->channel_layouts : |
... | ... |
@@ -349,7 +349,7 @@ static int request_samples(AVFilterContext *ctx, int min_samples) |
349 | 349 |
if (s->input_state[i] == INPUT_OFF) |
350 | 350 |
continue; |
351 | 351 |
while (!ret && av_audio_fifo_size(s->fifos[i]) < min_samples) |
352 |
- ret = avfilter_request_frame(ctx->inputs[i]); |
|
352 |
+ ret = ff_request_frame(ctx->inputs[i]); |
|
353 | 353 |
if (ret == AVERROR_EOF) { |
354 | 354 |
if (av_audio_fifo_size(s->fifos[i]) == 0) { |
355 | 355 |
s->input_state[i] = INPUT_OFF; |
... | ... |
@@ -410,7 +410,7 @@ static int request_frame(AVFilterLink *outlink) |
410 | 410 |
} |
411 | 411 |
|
412 | 412 |
if (s->frame_list->nb_frames == 0) { |
413 |
- ret = avfilter_request_frame(ctx->inputs[0]); |
|
413 |
+ ret = ff_request_frame(ctx->inputs[0]); |
|
414 | 414 |
if (ret == AVERROR_EOF) { |
415 | 415 |
s->input_state[0] = INPUT_OFF; |
416 | 416 |
if (s->nb_inputs == 1) |
... | ... |
@@ -497,7 +497,7 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque) |
497 | 497 |
pad.name = av_strdup(name); |
498 | 498 |
pad.filter_samples = filter_samples; |
499 | 499 |
|
500 |
- avfilter_insert_inpad(ctx, i, &pad); |
|
500 |
+ ff_insert_inpad(ctx, i, &pad); |
|
501 | 501 |
} |
502 | 502 |
|
503 | 503 |
return 0; |
... | ... |
@@ -525,8 +525,8 @@ static void uninit(AVFilterContext *ctx) |
525 | 525 |
static int query_formats(AVFilterContext *ctx) |
526 | 526 |
{ |
527 | 527 |
AVFilterFormats *formats = NULL; |
528 |
- avfilter_add_format(&formats, AV_SAMPLE_FMT_FLT); |
|
529 |
- avfilter_set_common_formats(ctx, formats); |
|
528 |
+ ff_add_format(&formats, AV_SAMPLE_FMT_FLT); |
|
529 |
+ ff_set_common_formats(ctx, formats); |
|
530 | 530 |
ff_set_common_channel_layouts(ctx, ff_all_channel_layouts()); |
531 | 531 |
ff_set_common_samplerates(ctx, ff_all_samplerates()); |
532 | 532 |
return 0; |
... | ... |
@@ -24,6 +24,7 @@ |
24 | 24 |
|
25 | 25 |
#include "audio.h" |
26 | 26 |
#include "avfilter.h" |
27 |
+#include "internal.h" |
|
27 | 28 |
|
28 | 29 |
typedef struct ASyncContext { |
29 | 30 |
const AVClass *class; |
... | ... |
@@ -116,7 +117,7 @@ static int request_frame(AVFilterLink *link) |
116 | 116 |
{ |
117 | 117 |
AVFilterContext *ctx = link->src; |
118 | 118 |
ASyncContext *s = ctx->priv; |
119 |
- int ret = avfilter_request_frame(ctx->inputs[0]); |
|
119 |
+ int ret = ff_request_frame(ctx->inputs[0]); |
|
120 | 120 |
int nb_samples; |
121 | 121 |
|
122 | 122 |
/* flush the fifo */ |
... | ... |
@@ -55,18 +55,18 @@ static int query_formats(AVFilterContext *ctx) |
55 | 55 |
AVFilterLink *inlink = ctx->inputs[0]; |
56 | 56 |
AVFilterLink *outlink = ctx->outputs[0]; |
57 | 57 |
|
58 |
- AVFilterFormats *in_formats = avfilter_all_formats(AVMEDIA_TYPE_AUDIO); |
|
59 |
- AVFilterFormats *out_formats = avfilter_all_formats(AVMEDIA_TYPE_AUDIO); |
|
58 |
+ AVFilterFormats *in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); |
|
59 |
+ AVFilterFormats *out_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); |
|
60 | 60 |
AVFilterFormats *in_samplerates = ff_all_samplerates(); |
61 | 61 |
AVFilterFormats *out_samplerates = ff_all_samplerates(); |
62 | 62 |
AVFilterChannelLayouts *in_layouts = ff_all_channel_layouts(); |
63 | 63 |
AVFilterChannelLayouts *out_layouts = ff_all_channel_layouts(); |
64 | 64 |
|
65 |
- avfilter_formats_ref(in_formats, &inlink->out_formats); |
|
66 |
- avfilter_formats_ref(out_formats, &outlink->in_formats); |
|
65 |
+ ff_formats_ref(in_formats, &inlink->out_formats); |
|
66 |
+ ff_formats_ref(out_formats, &outlink->in_formats); |
|
67 | 67 |
|
68 |
- avfilter_formats_ref(in_samplerates, &inlink->out_samplerates); |
|
69 |
- avfilter_formats_ref(out_samplerates, &outlink->in_samplerates); |
|
68 |
+ ff_formats_ref(in_samplerates, &inlink->out_samplerates); |
|
69 |
+ ff_formats_ref(out_samplerates, &outlink->in_samplerates); |
|
70 | 70 |
|
71 | 71 |
ff_channel_layouts_ref(in_layouts, &inlink->out_channel_layouts); |
72 | 72 |
ff_channel_layouts_ref(out_layouts, &outlink->in_channel_layouts); |
... | ... |
@@ -130,7 +130,7 @@ static int request_frame(AVFilterLink *outlink) |
130 | 130 |
{ |
131 | 131 |
AVFilterContext *ctx = outlink->src; |
132 | 132 |
ResampleContext *s = ctx->priv; |
133 |
- int ret = avfilter_request_frame(ctx->inputs[0]); |
|
133 |
+ int ret = ff_request_frame(ctx->inputs[0]); |
|
134 | 134 |
|
135 | 135 |
/* flush the lavr delay buffer */ |
136 | 136 |
if (ret == AVERROR_EOF && s->avr) { |
... | ... |
@@ -96,9 +96,9 @@ void ff_command_queue_pop(AVFilterContext *filter) |
96 | 96 |
av_free(c); |
97 | 97 |
} |
98 | 98 |
|
99 |
-void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, |
|
100 |
- AVFilterPad **pads, AVFilterLink ***links, |
|
101 |
- AVFilterPad *newpad) |
|
99 |
+void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, |
|
100 |
+ AVFilterPad **pads, AVFilterLink ***links, |
|
101 |
+ AVFilterPad *newpad) |
|
102 | 102 |
{ |
103 | 103 |
unsigned i; |
104 | 104 |
|
... | ... |
@@ -183,14 +183,15 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, |
183 | 183 |
/* if any information on supported media formats already exists on the |
184 | 184 |
* link, we need to preserve that */ |
185 | 185 |
if (link->out_formats) |
186 |
- avfilter_formats_changeref(&link->out_formats, |
|
186 |
+ ff_formats_changeref(&link->out_formats, |
|
187 | 187 |
&filt->outputs[filt_dstpad_idx]->out_formats); |
188 |
+ |
|
189 |
+ if (link->out_samplerates) |
|
190 |
+ ff_formats_changeref(&link->out_samplerates, |
|
191 |
+ &filt->outputs[filt_dstpad_idx]->out_samplerates); |
|
188 | 192 |
if (link->out_channel_layouts) |
189 | 193 |
ff_channel_layouts_changeref(&link->out_channel_layouts, |
190 | 194 |
&filt->outputs[filt_dstpad_idx]->out_channel_layouts); |
191 |
- if (link->out_samplerates) |
|
192 |
- avfilter_formats_changeref(&link->out_samplerates, |
|
193 |
- &filt->outputs[filt_dstpad_idx]->out_samplerates); |
|
194 | 195 |
|
195 | 196 |
return 0; |
196 | 197 |
} |
... | ... |
@@ -307,18 +308,18 @@ void ff_dlog_link(void *ctx, AVFilterLink *link, int end) |
307 | 307 |
} |
308 | 308 |
} |
309 | 309 |
|
310 |
-int avfilter_request_frame(AVFilterLink *link) |
|
310 |
+int ff_request_frame(AVFilterLink *link) |
|
311 | 311 |
{ |
312 | 312 |
FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1); |
313 | 313 |
|
314 | 314 |
if (link->srcpad->request_frame) |
315 | 315 |
return link->srcpad->request_frame(link); |
316 | 316 |
else if (link->src->inputs[0]) |
317 |
- return avfilter_request_frame(link->src->inputs[0]); |
|
317 |
+ return ff_request_frame(link->src->inputs[0]); |
|
318 | 318 |
else return -1; |
319 | 319 |
} |
320 | 320 |
|
321 |
-int avfilter_poll_frame(AVFilterLink *link) |
|
321 |
+int ff_poll_frame(AVFilterLink *link) |
|
322 | 322 |
{ |
323 | 323 |
int i, min = INT_MAX; |
324 | 324 |
|
... | ... |
@@ -329,7 +330,7 @@ int avfilter_poll_frame(AVFilterLink *link) |
329 | 329 |
int val; |
330 | 330 |
if (!link->src->inputs[i]) |
331 | 331 |
return -1; |
332 |
- val = avfilter_poll_frame(link->src->inputs[i]); |
|
332 |
+ val = ff_poll_frame(link->src->inputs[i]); |
|
333 | 333 |
min = FFMIN(min, val); |
334 | 334 |
} |
335 | 335 |
|
... | ... |
@@ -492,10 +493,10 @@ void avfilter_free(AVFilterContext *filter) |
492 | 492 |
if ((link = filter->inputs[i])) { |
493 | 493 |
if (link->src) |
494 | 494 |
link->src->outputs[link->srcpad - link->src->output_pads] = NULL; |
495 |
- avfilter_formats_unref(&link->in_formats); |
|
496 |
- avfilter_formats_unref(&link->out_formats); |
|
497 |
- avfilter_formats_unref(&link->in_samplerates); |
|
498 |
- avfilter_formats_unref(&link->out_samplerates); |
|
495 |
+ ff_formats_unref(&link->in_formats); |
|
496 |
+ ff_formats_unref(&link->out_formats); |
|
497 |
+ ff_formats_unref(&link->in_samplerates); |
|
498 |
+ ff_formats_unref(&link->out_samplerates); |
|
499 | 499 |
ff_channel_layouts_unref(&link->in_channel_layouts); |
500 | 500 |
ff_channel_layouts_unref(&link->out_channel_layouts); |
501 | 501 |
} |
... | ... |
@@ -505,10 +506,10 @@ void avfilter_free(AVFilterContext *filter) |
505 | 505 |
if ((link = filter->outputs[i])) { |
506 | 506 |
if (link->dst) |
507 | 507 |
link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL; |
508 |
- avfilter_formats_unref(&link->in_formats); |
|
509 |
- avfilter_formats_unref(&link->out_formats); |
|
510 |
- avfilter_formats_unref(&link->in_samplerates); |
|
511 |
- avfilter_formats_unref(&link->out_samplerates); |
|
508 |
+ ff_formats_unref(&link->in_formats); |
|
509 |
+ ff_formats_unref(&link->out_formats); |
|
510 |
+ ff_formats_unref(&link->in_samplerates); |
|
511 |
+ ff_formats_unref(&link->out_samplerates); |
|
512 | 512 |
ff_channel_layouts_unref(&link->in_channel_layouts); |
513 | 513 |
ff_channel_layouts_unref(&link->out_channel_layouts); |
514 | 514 |
} |
... | ... |
@@ -535,3 +536,32 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque |
535 | 535 |
ret = filter->filter->init(filter, args, opaque); |
536 | 536 |
return ret; |
537 | 537 |
} |
538 |
+ |
|
539 |
+#if FF_API_DEFAULT_CONFIG_OUTPUT_LINK |
|
540 |
+void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, |
|
541 |
+ AVFilterPad **pads, AVFilterLink ***links, |
|
542 |
+ AVFilterPad *newpad) |
|
543 |
+{ |
|
544 |
+ ff_insert_pad(idx, count, padidx_off, pads, links, newpad); |
|
545 |
+} |
|
546 |
+void avfilter_insert_inpad(AVFilterContext *f, unsigned index, |
|
547 |
+ AVFilterPad *p) |
|
548 |
+{ |
|
549 |
+ ff_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad), |
|
550 |
+ &f->input_pads, &f->inputs, p); |
|
551 |
+} |
|
552 |
+void avfilter_insert_outpad(AVFilterContext *f, unsigned index, |
|
553 |
+ AVFilterPad *p) |
|
554 |
+{ |
|
555 |
+ ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad), |
|
556 |
+ &f->output_pads, &f->outputs, p); |
|
557 |
+} |
|
558 |
+int avfilter_poll_frame(AVFilterLink *link) |
|
559 |
+{ |
|
560 |
+ return ff_poll_frame(link); |
|
561 |
+} |
|
562 |
+int avfilter_request_frame(AVFilterLink *link) |
|
563 |
+{ |
|
564 |
+ return ff_request_frame(link); |
|
565 |
+} |
|
566 |
+#endif |
... | ... |
@@ -60,6 +60,7 @@ const char *avfilter_license(void); |
60 | 60 |
typedef struct AVFilterContext AVFilterContext; |
61 | 61 |
typedef struct AVFilterLink AVFilterLink; |
62 | 62 |
typedef struct AVFilterPad AVFilterPad; |
63 |
+typedef struct AVFilterFormats AVFilterFormats; |
|
63 | 64 |
|
64 | 65 |
/** |
65 | 66 |
* A reference-counted buffer data type used by the filter system. Filters |
... | ... |
@@ -210,6 +211,7 @@ AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask); |
210 | 210 |
*/ |
211 | 211 |
void avfilter_unref_buffer(AVFilterBufferRef *ref); |
212 | 212 |
|
213 |
+#if FF_API_FILTERS_PUBLIC |
|
213 | 214 |
/** |
214 | 215 |
* Remove a reference to a buffer and set the pointer to NULL. |
215 | 216 |
* If this is the last reference to the buffer, the buffer itself |
... | ... |
@@ -258,14 +260,18 @@ void avfilter_unref_bufferp(AVFilterBufferRef **ref); |
258 | 258 |
* we must ensure that all links which reference either pre-merge format list |
259 | 259 |
* get updated as well. Therefore, we have the format list structure store a |
260 | 260 |
* pointer to each of the pointers to itself. |
261 |
+ * @addtogroup lavfi_deprecated |
|
262 |
+ * @deprecated Those functions are only useful inside filters and |
|
263 |
+ * user filters are not supported at this point. |
|
264 |
+ * @{ |
|
261 | 265 |
*/ |
262 |
-typedef struct AVFilterFormats { |
|
266 |
+struct AVFilterFormats { |
|
263 | 267 |
unsigned format_count; ///< number of formats |
264 | 268 |
int *formats; ///< list of media formats |
265 | 269 |
|
266 | 270 |
unsigned refcount; ///< number of references to this list |
267 | 271 |
struct AVFilterFormats ***refs; ///< references to this list |
268 |
-} AVFilterFormats; |
|
272 |
+}; |
|
269 | 273 |
|
270 | 274 |
/** |
271 | 275 |
* Create a list of supported formats. This is intended for use in |
... | ... |
@@ -275,6 +281,7 @@ typedef struct AVFilterFormats { |
275 | 275 |
* empty list is created. |
276 | 276 |
* @return the format list, with no existing references |
277 | 277 |
*/ |
278 |
+attribute_deprecated |
|
278 | 279 |
AVFilterFormats *avfilter_make_format_list(const int *fmts); |
279 | 280 |
|
280 | 281 |
/** |
... | ... |
@@ -284,16 +291,12 @@ AVFilterFormats *avfilter_make_format_list(const int *fmts); |
284 | 284 |
* |
285 | 285 |
* @return a non negative value in case of success, or a negative |
286 | 286 |
* value corresponding to an AVERROR code in case of error |
287 |
- */ |
|
288 |
-int avfilter_add_format(AVFilterFormats **avff, int64_t fmt); |
|
289 |
- |
|
290 |
-#if FF_API_OLD_ALL_FORMATS_API |
|
291 |
-/** |
|
292 | 287 |
* @deprecated Use avfilter_make_all_formats() instead. |
293 | 288 |
*/ |
294 | 289 |
attribute_deprecated |
290 |
+int avfilter_add_format(AVFilterFormats **avff, int64_t fmt); |
|
291 |
+attribute_deprecated |
|
295 | 292 |
AVFilterFormats *avfilter_all_formats(enum AVMediaType type); |
296 |
-#endif |
|
297 | 293 |
|
298 | 294 |
/** |
299 | 295 |
* Return a list of all formats supported by FFmpeg for the given media type. |
... | ... |
@@ -320,6 +323,7 @@ AVFilterFormats *avfilter_make_all_packing_formats(void); |
320 | 320 |
* If a and b do not share any common formats, neither is modified, and NULL |
321 | 321 |
* is returned. |
322 | 322 |
*/ |
323 |
+attribute_deprecated |
|
323 | 324 |
AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b); |
324 | 325 |
|
325 | 326 |
/** |
... | ... |
@@ -334,40 +338,36 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b); |
334 | 334 |
* | |____| | | |____| |
335 | 335 |
* |________| |________________________ |
336 | 336 |
*/ |
337 |
+attribute_deprecated |
|
337 | 338 |
void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref); |
338 |
- |
|
339 |
+attribute_deprecated |
|
340 |
+void avfilter_formats_unref(AVFilterFormats **ref); |
|
341 |
+attribute_deprecated |
|
342 |
+void avfilter_formats_changeref(AVFilterFormats **oldref, |
|
343 |
+ AVFilterFormats **newref); |
|
339 | 344 |
/** |
340 |
- * If *ref is non-NULL, remove *ref as a reference to the format list |
|
341 |
- * it currently points to, deallocates that list if this was the last |
|
342 |
- * reference, and sets *ref to NULL. |
|
343 |
- * |
|
344 |
- * Before After |
|
345 |
- * ________ ________ NULL |
|
346 |
- * |formats |<--------. |formats | ^ |
|
347 |
- * | ____ | ____|________________ | ____ | ____|________________ |
|
348 |
- * | |refs| | | __|_ | |refs| | | __|_ |
|
349 |
- * | |* * | | | | | | AVFilterLink | |* * | | | | | | AVFilterLink |
|
350 |
- * | |* *--------->|*ref| | |* | | | |*ref| |
|
351 |
- * | |____| | | |____| | |____| | | |____| |
|
352 |
- * |________| |_____________________ |________| |_____________________ |
|
345 |
+ * Helpers for query_formats() which set all links to the same list of |
|
346 |
+ * formats/layouts. If there are no links hooked to this filter, the list |
|
347 |
+ * of formats is freed. |
|
353 | 348 |
*/ |
354 |
-void avfilter_formats_unref(AVFilterFormats **ref); |
|
349 |
+attribute_deprecated |
|
350 |
+void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
|
351 |
+ |
|
352 |
+attribute_deprecated |
|
353 |
+void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
|
354 |
+attribute_deprecated |
|
355 |
+void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
|
356 |
+attribute_deprecated |
|
357 |
+void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats); |
|
358 |
+#if FF_API_PACKING |
|
359 |
+attribute_deprecated |
|
360 |
+void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
|
361 |
+#endif |
|
355 | 362 |
|
356 | 363 |
/** |
357 |
- * |
|
358 |
- * Before After |
|
359 |
- * ________ ________ |
|
360 |
- * |formats |<---------. |formats |<---------. |
|
361 |
- * | ____ | ___|___ | ____ | ___|___ |
|
362 |
- * | |refs| | | | | | |refs| | | | | NULL |
|
363 |
- * | |* *--------->|*oldref| | |* *--------->|*newref| ^ |
|
364 |
- * | |* * | | |_______| | |* * | | |_______| ___|___ |
|
365 |
- * | |____| | | |____| | | | | |
|
366 |
- * |________| |________| |*oldref| |
|
367 |
- * |_______| |
|
364 |
+ * @} |
|
368 | 365 |
*/ |
369 |
-void avfilter_formats_changeref(AVFilterFormats **oldref, |
|
370 |
- AVFilterFormats **newref); |
|
366 |
+#endif |
|
371 | 367 |
|
372 | 368 |
/** |
373 | 369 |
* A filter pad used for either input or output. |
... | ... |
@@ -523,19 +523,6 @@ attribute_deprecated |
523 | 523 |
int avfilter_default_query_formats(AVFilterContext *ctx); |
524 | 524 |
#endif |
525 | 525 |
|
526 |
-/** |
|
527 |
- * Helpers for query_formats() which set all links to the same list of |
|
528 |
- * formats/layouts. If there are no links hooked to this filter, the list |
|
529 |
- * of formats is freed. |
|
530 |
- */ |
|
531 |
-void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
|
532 |
-void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
|
533 |
-void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
|
534 |
-void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats); |
|
535 |
-#if FF_API_PACKING |
|
536 |
-void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
|
537 |
-#endif |
|
538 |
- |
|
539 | 526 |
#if FF_API_FILTERS_PUBLIC |
540 | 527 |
/** start_frame() handler for filters which simply pass video along */ |
541 | 528 |
attribute_deprecated |
... | ... |
@@ -831,6 +818,7 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, |
831 | 831 |
enum AVSampleFormat sample_fmt, |
832 | 832 |
uint64_t channel_layout); |
833 | 833 |
|
834 |
+#if FF_API_FILTERS_PUBLIC |
|
834 | 835 |
/** |
835 | 836 |
* Request an input frame from the filter at the other end of the link. |
836 | 837 |
* |
... | ... |
@@ -842,24 +830,10 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, |
842 | 842 |
*/ |
843 | 843 |
int avfilter_request_frame(AVFilterLink *link); |
844 | 844 |
|
845 |
-/** |
|
846 |
- * Poll a frame from the filter chain. |
|
847 |
- * |
|
848 |
- * @param link the input link |
|
849 |
- * @return the number of immediately available frames, a negative |
|
850 |
- * number in case of error |
|
851 |
- */ |
|
845 |
+attribute_deprecated |
|
852 | 846 |
int avfilter_poll_frame(AVFilterLink *link); |
853 | 847 |
|
854 |
-/** |
|
855 |
- * Notify the next filter of the start of a frame. |
|
856 |
- * |
|
857 |
- * @param link the output link the frame will be sent over |
|
858 |
- * @param picref A reference to the frame about to be sent. The data for this |
|
859 |
- * frame need only be valid once draw_slice() is called for that |
|
860 |
- * portion. The receiving filter will free this reference when |
|
861 |
- * it no longer needs it. |
|
862 |
- */ |
|
848 |
+attribute_deprecated |
|
863 | 849 |
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); |
864 | 850 |
|
865 | 851 |
/** |
... | ... |
@@ -867,24 +841,11 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); |
867 | 867 |
* |
868 | 868 |
* @param link the output link the frame was sent over |
869 | 869 |
*/ |
870 |
+attribute_deprecated |
|
870 | 871 |
void avfilter_end_frame(AVFilterLink *link); |
871 |
- |
|
872 |
-/** |
|
873 |
- * Send a slice to the next filter. |
|
874 |
- * |
|
875 |
- * Slices have to be provided in sequential order, either in |
|
876 |
- * top-bottom or bottom-top order. If slices are provided in |
|
877 |
- * non-sequential order the behavior of the function is undefined. |
|
878 |
- * |
|
879 |
- * @param link the output link over which the frame is being sent |
|
880 |
- * @param y offset in pixels from the top of the image for this slice |
|
881 |
- * @param h height of this slice in pixels |
|
882 |
- * @param slice_dir the assumed direction for sending slices, |
|
883 |
- * from the top slice to the bottom slice if the value is 1, |
|
884 |
- * from the bottom slice to the top slice if the value is -1, |
|
885 |
- * for other values the behavior of the function is undefined. |
|
886 |
- */ |
|
872 |
+attribute_deprecated |
|
887 | 873 |
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); |
874 |
+#endif |
|
888 | 875 |
|
889 | 876 |
#define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically |
890 | 877 |
#define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw) |
... | ... |
@@ -972,37 +933,18 @@ void avfilter_free(AVFilterContext *filter); |
972 | 972 |
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, |
973 | 973 |
unsigned filt_srcpad_idx, unsigned filt_dstpad_idx); |
974 | 974 |
|
975 |
-/** |
|
976 |
- * Insert a new pad. |
|
977 |
- * |
|
978 |
- * @param idx Insertion point. Pad is inserted at the end if this point |
|
979 |
- * is beyond the end of the list of pads. |
|
980 |
- * @param count Pointer to the number of pads in the list |
|
981 |
- * @param padidx_off Offset within an AVFilterLink structure to the element |
|
982 |
- * to increment when inserting a new pad causes link |
|
983 |
- * numbering to change |
|
984 |
- * @param pads Pointer to the pointer to the beginning of the list of pads |
|
985 |
- * @param links Pointer to the pointer to the beginning of the list of links |
|
986 |
- * @param newpad The new pad to add. A copy is made when adding. |
|
987 |
- */ |
|
975 |
+#if FF_API_FILTERS_PUBLIC |
|
976 |
+attribute_deprecated |
|
988 | 977 |
void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, |
989 | 978 |
AVFilterPad **pads, AVFilterLink ***links, |
990 | 979 |
AVFilterPad *newpad); |
991 | 980 |
|
992 |
-/** Insert a new input pad for the filter. */ |
|
993 |
-static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index, |
|
994 |
- AVFilterPad *p) |
|
995 |
-{ |
|
996 |
- avfilter_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad), |
|
997 |
- &f->input_pads, &f->inputs, p); |
|
998 |
-} |
|
999 |
- |
|
1000 |
-/** Insert a new output pad for the filter. */ |
|
1001 |
-static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index, |
|
1002 |
- AVFilterPad *p) |
|
1003 |
-{ |
|
1004 |
- avfilter_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad), |
|
1005 |
- &f->output_pads, &f->outputs, p); |
|
1006 |
-} |
|
981 |
+attribute_deprecated |
|
982 |
+void avfilter_insert_inpad(AVFilterContext *f, unsigned index, |
|
983 |
+ AVFilterPad *p); |
|
984 |
+attribute_deprecated |
|
985 |
+void avfilter_insert_outpad(AVFilterContext *f, unsigned index, |
|
986 |
+ AVFilterPad *p); |
|
987 |
+#endif |
|
1007 | 988 |
|
1008 | 989 |
#endif /* AVFILTER_AVFILTER_H */ |
... | ... |
@@ -324,7 +324,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) |
324 | 324 |
continue; |
325 | 325 |
|
326 | 326 |
if (link->in_formats != link->out_formats && |
327 |
- !avfilter_merge_formats(link->in_formats, |
|
327 |
+ !ff_merge_formats(link->in_formats, |
|
328 | 328 |
link->out_formats)) |
329 | 329 |
convert_needed = 1; |
330 | 330 |
if (link->type == AVMEDIA_TYPE_AUDIO) { |
... | ... |
@@ -381,8 +381,8 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) |
381 | 381 |
filter_query_formats(convert); |
382 | 382 |
inlink = convert->inputs[0]; |
383 | 383 |
outlink = convert->outputs[0]; |
384 |
- if (!avfilter_merge_formats( inlink->in_formats, inlink->out_formats) || |
|
385 |
- !avfilter_merge_formats(outlink->in_formats, outlink->out_formats)) |
|
384 |
+ if (!ff_merge_formats( inlink->in_formats, inlink->out_formats) || |
|
385 |
+ !ff_merge_formats(outlink->in_formats, outlink->out_formats)) |
|
386 | 386 |
ret |= AVERROR(ENOSYS); |
387 | 387 |
if (inlink->type == AVMEDIA_TYPE_AUDIO && |
388 | 388 |
(!ff_merge_samplerates(inlink->in_samplerates, |
... | ... |
@@ -452,10 +452,10 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) |
452 | 452 |
link->channel_layout = link->in_channel_layouts->channel_layouts[0]; |
453 | 453 |
} |
454 | 454 |
|
455 |
- avfilter_formats_unref(&link->in_formats); |
|
456 |
- avfilter_formats_unref(&link->out_formats); |
|
457 |
- avfilter_formats_unref(&link->in_samplerates); |
|
458 |
- avfilter_formats_unref(&link->out_samplerates); |
|
455 |
+ ff_formats_unref(&link->in_formats); |
|
456 |
+ ff_formats_unref(&link->out_formats); |
|
457 |
+ ff_formats_unref(&link->in_samplerates); |
|
458 |
+ ff_formats_unref(&link->out_samplerates); |
|
459 | 459 |
ff_channel_layouts_unref(&link->in_channel_layouts); |
460 | 460 |
ff_channel_layouts_unref(&link->out_channel_layouts); |
461 | 461 |
|
... | ... |
@@ -502,9 +502,9 @@ static int reduce_formats_on_filter(AVFilterContext *filter) |
502 | 502 |
int i, j, k, ret = 0; |
503 | 503 |
|
504 | 504 |
REDUCE_FORMATS(int, AVFilterFormats, formats, formats, |
505 |
- format_count, avfilter_add_format); |
|
505 |
+ format_count, ff_add_format); |
|
506 | 506 |
REDUCE_FORMATS(int, AVFilterFormats, samplerates, formats, |
507 |
- format_count, avfilter_add_format); |
|
507 |
+ format_count, ff_add_format); |
|
508 | 508 |
REDUCE_FORMATS(uint64_t, AVFilterChannelLayouts, channel_layouts, |
509 | 509 |
channel_layouts, nb_channel_layouts, ff_add_channel_layout); |
510 | 510 |
|
... | ... |
@@ -31,6 +31,7 @@ |
31 | 31 |
#include "audio.h" |
32 | 32 |
#include "avfilter.h" |
33 | 33 |
#include "buffersink.h" |
34 |
+#include "internal.h" |
|
34 | 35 |
|
35 | 36 |
typedef struct { |
36 | 37 |
AVFifoBuffer *fifo; ///< FIFO buffer of frame references |
... | ... |
@@ -102,11 +103,11 @@ int av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf) |
102 | 102 |
if (av_fifo_size(sink->fifo)) |
103 | 103 |
return av_fifo_size(sink->fifo)/sizeof(*buf); |
104 | 104 |
else |
105 |
- return avfilter_poll_frame(ctx->inputs[0]); |
|
105 |
+ return ff_poll_frame(ctx->inputs[0]); |
|
106 | 106 |
} |
107 | 107 |
|
108 | 108 |
if (!av_fifo_size(sink->fifo) && |
109 |
- (ret = avfilter_request_frame(link)) < 0) |
|
109 |
+ (ret = ff_request_frame(link)) < 0) |
|
110 | 110 |
return ret; |
111 | 111 |
|
112 | 112 |
if (!av_fifo_size(sink->fifo)) |
... | ... |
@@ -28,6 +28,7 @@ |
28 | 28 |
#include "buffersrc.h" |
29 | 29 |
#include "formats.h" |
30 | 30 |
#include "internal.h" |
31 |
+#include "video.h" |
|
31 | 32 |
#include "vsrc_buffer.h" |
32 | 33 |
#include "avcodec.h" |
33 | 34 |
|
... | ... |
@@ -328,14 +329,14 @@ static int query_formats(AVFilterContext *ctx) |
328 | 328 |
|
329 | 329 |
switch (ctx->outputs[0]->type) { |
330 | 330 |
case AVMEDIA_TYPE_VIDEO: |
331 |
- avfilter_add_format(&formats, c->pix_fmt); |
|
332 |
- avfilter_set_common_formats(ctx, formats); |
|
331 |
+ ff_add_format(&formats, c->pix_fmt); |
|
332 |
+ ff_set_common_formats(ctx, formats); |
|
333 | 333 |
break; |
334 | 334 |
case AVMEDIA_TYPE_AUDIO: |
335 |
- avfilter_add_format(&formats, c->sample_fmt); |
|
336 |
- avfilter_set_common_formats(ctx, formats); |
|
335 |
+ ff_add_format(&formats, c->sample_fmt); |
|
336 |
+ ff_set_common_formats(ctx, formats); |
|
337 | 337 |
|
338 |
- avfilter_add_format(&samplerates, c->sample_rate); |
|
338 |
+ ff_add_format(&samplerates, c->sample_rate); |
|
339 | 339 |
ff_set_common_samplerates(ctx, samplerates); |
340 | 340 |
|
341 | 341 |
ff_add_channel_layout(&channel_layouts, c->channel_layout); |
... | ... |
@@ -385,9 +386,9 @@ static int request_frame(AVFilterLink *link) |
385 | 385 |
|
386 | 386 |
switch (link->type) { |
387 | 387 |
case AVMEDIA_TYPE_VIDEO: |
388 |
- avfilter_start_frame(link, avfilter_ref_buffer(buf, ~0)); |
|
389 |
- avfilter_draw_slice(link, 0, link->h, 1); |
|
390 |
- avfilter_end_frame(link); |
|
388 |
+ ff_start_frame(link, avfilter_ref_buffer(buf, ~0)); |
|
389 |
+ ff_draw_slice(link, 0, link->h, 1); |
|
390 |
+ ff_end_frame(link); |
|
391 | 391 |
break; |
392 | 392 |
case AVMEDIA_TYPE_AUDIO: |
393 | 393 |
ff_filter_samples(link, avfilter_ref_buffer(buf, ~0)); |
... | ... |
@@ -85,7 +85,7 @@ do { |
85 | 85 |
MERGE_REF(ret, b, fmts, type, fail); \ |
86 | 86 |
} while (0) |
87 | 87 |
|
88 |
-AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) |
|
88 |
+AVFilterFormats *ff_merge_formats(AVFilterFormats *a, AVFilterFormats *b) |
|
89 | 89 |
{ |
90 | 90 |
AVFilterFormats *ret = NULL; |
91 | 91 |
|
... | ... |
@@ -213,7 +213,7 @@ int64_t *ff_copy_int64_list(const int64_t * const list) |
213 | 213 |
} \ |
214 | 214 |
} |
215 | 215 |
|
216 |
-AVFilterFormats *avfilter_make_format_list(const int *fmts) |
|
216 |
+AVFilterFormats *ff_make_format_list(const int *fmts) |
|
217 | 217 |
{ |
218 | 218 |
MAKE_FORMAT_LIST(AVFilterFormats, formats, format_count); |
219 | 219 |
while (count--) |
... | ... |
@@ -250,7 +250,7 @@ do { \ |
250 | 250 |
return 0; \ |
251 | 251 |
} while (0) |
252 | 252 |
|
253 |
-int avfilter_add_format(AVFilterFormats **avff, int64_t fmt) |
|
253 |
+int ff_add_format(AVFilterFormats **avff, int64_t fmt) |
|
254 | 254 |
{ |
255 | 255 |
ADD_FORMAT(avff, fmt, int, formats, format_count); |
256 | 256 |
} |
... | ... |
@@ -260,12 +260,10 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout) |
260 | 260 |
ADD_FORMAT(l, channel_layout, uint64_t, channel_layouts, nb_channel_layouts); |
261 | 261 |
} |
262 | 262 |
|
263 |
-#if FF_API_OLD_ALL_FORMATS_API |
|
264 |
-AVFilterFormats *avfilter_all_formats(enum AVMediaType type) |
|
263 |
+AVFilterFormats *ff_all_formats(enum AVMediaType type) |
|
265 | 264 |
{ |
266 | 265 |
return avfilter_make_all_formats(type); |
267 | 266 |
} |
268 |
-#endif |
|
269 | 267 |
|
270 | 268 |
AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type) |
271 | 269 |
{ |
... | ... |
@@ -277,7 +275,7 @@ AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type) |
277 | 277 |
for (fmt = 0; fmt < num_formats; fmt++) |
278 | 278 |
if ((type != AVMEDIA_TYPE_VIDEO) || |
279 | 279 |
(type == AVMEDIA_TYPE_VIDEO && !(av_pix_fmt_descriptors[fmt].flags & PIX_FMT_HWACCEL))) |
280 |
- avfilter_add_format(&ret, fmt); |
|
280 |
+ ff_add_format(&ret, fmt); |
|
281 | 281 |
|
282 | 282 |
return ret; |
283 | 283 |
} |
... | ... |
@@ -329,7 +327,7 @@ void ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts ** |
329 | 329 |
FORMATS_REF(f, ref); |
330 | 330 |
} |
331 | 331 |
|
332 |
-void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) |
|
332 |
+void ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) |
|
333 | 333 |
{ |
334 | 334 |
FORMATS_REF(f, ref); |
335 | 335 |
} |
... | ... |
@@ -365,7 +363,7 @@ do { \ |
365 | 365 |
*ref = NULL; \ |
366 | 366 |
} while (0) |
367 | 367 |
|
368 |
-void avfilter_formats_unref(AVFilterFormats **ref) |
|
368 |
+void ff_formats_unref(AVFilterFormats **ref) |
|
369 | 369 |
{ |
370 | 370 |
FORMATS_UNREF(ref, formats); |
371 | 371 |
} |
... | ... |
@@ -394,8 +392,7 @@ void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, |
394 | 394 |
FORMATS_CHANGEREF(oldref, newref); |
395 | 395 |
} |
396 | 396 |
|
397 |
-void avfilter_formats_changeref(AVFilterFormats **oldref, |
|
398 |
- AVFilterFormats **newref) |
|
397 |
+void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) |
|
399 | 398 |
{ |
400 | 399 |
FORMATS_CHANGEREF(oldref, newref); |
401 | 400 |
} |
... | ... |
@@ -435,7 +432,7 @@ void ff_set_common_samplerates(AVFilterContext *ctx, |
435 | 435 |
AVFilterFormats *samplerates) |
436 | 436 |
{ |
437 | 437 |
SET_COMMON_FORMATS(ctx, samplerates, in_samplerates, out_samplerates, |
438 |
- avfilter_formats_ref, formats); |
|
438 |
+ ff_formats_ref, formats); |
|
439 | 439 |
} |
440 | 440 |
|
441 | 441 |
/** |
... | ... |
@@ -443,10 +440,10 @@ void ff_set_common_samplerates(AVFilterContext *ctx, |
443 | 443 |
* formats. If there are no links hooked to this filter, the list of formats is |
444 | 444 |
* freed. |
445 | 445 |
*/ |
446 |
-void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) |
|
446 |
+void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) |
|
447 | 447 |
{ |
448 | 448 |
SET_COMMON_FORMATS(ctx, formats, in_formats, out_formats, |
449 |
- avfilter_formats_ref, formats); |
|
449 |
+ ff_formats_ref, formats); |
|
450 | 450 |
} |
451 | 451 |
|
452 | 452 |
int ff_default_query_formats(AVFilterContext *ctx) |
... | ... |
@@ -455,7 +452,7 @@ int ff_default_query_formats(AVFilterContext *ctx) |
455 | 455 |
ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type : |
456 | 456 |
AVMEDIA_TYPE_VIDEO; |
457 | 457 |
|
458 |
- avfilter_set_common_formats(ctx, avfilter_all_formats(type)); |
|
458 |
+ ff_set_common_formats(ctx, ff_all_formats(type)); |
|
459 | 459 |
if (type == AVMEDIA_TYPE_AUDIO) { |
460 | 460 |
ff_set_common_channel_layouts(ctx, ff_all_channel_layouts()); |
461 | 461 |
ff_set_common_samplerates(ctx, ff_all_samplerates()); |
... | ... |
@@ -539,6 +536,39 @@ int avfilter_default_query_formats(AVFilterContext *ctx) |
539 | 539 |
{ |
540 | 540 |
return ff_default_query_formats(ctx); |
541 | 541 |
} |
542 |
+void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) |
|
543 |
+{ |
|
544 |
+ ff_set_common_formats(ctx, formats); |
|
545 |
+} |
|
546 |
+AVFilterFormats *avfilter_make_format_list(const int *fmts) |
|
547 |
+{ |
|
548 |
+ return ff_make_format_list(fmts); |
|
549 |
+} |
|
550 |
+int avfilter_add_format(AVFilterFormats **avff, int64_t fmt) |
|
551 |
+{ |
|
552 |
+ return ff_add_format(avff, fmt); |
|
553 |
+} |
|
554 |
+AVFilterFormats *avfilter_all_formats(enum AVMediaType type) |
|
555 |
+{ |
|
556 |
+ return ff_all_formats(type); |
|
557 |
+} |
|
558 |
+AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) |
|
559 |
+{ |
|
560 |
+ return ff_merge_formats(a, b); |
|
561 |
+} |
|
562 |
+void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) |
|
563 |
+{ |
|
564 |
+ ff_formats_ref(f, ref); |
|
565 |
+} |
|
566 |
+void avfilter_formats_unref(AVFilterFormats **ref) |
|
567 |
+{ |
|
568 |
+ ff_formats_unref(ref); |
|
569 |
+} |
|
570 |
+void avfilter_formats_changeref(AVFilterFormats **oldref, |
|
571 |
+ AVFilterFormats **newref) |
|
572 |
+{ |
|
573 |
+ ff_formats_changeref(oldref, newref); |
|
574 |
+} |
|
542 | 575 |
#endif |
543 | 576 |
#ifdef TEST |
544 | 577 |
|
... | ... |
@@ -21,6 +21,56 @@ |
21 | 21 |
|
22 | 22 |
#include "avfilter.h" |
23 | 23 |
|
24 |
+/** |
|
25 |
+ * A list of supported formats for one end of a filter link. This is used |
|
26 |
+ * during the format negotiation process to try to pick the best format to |
|
27 |
+ * use to minimize the number of necessary conversions. Each filter gives a |
|
28 |
+ * list of the formats supported by each input and output pad. The list |
|
29 |
+ * given for each pad need not be distinct - they may be references to the |
|
30 |
+ * same list of formats, as is often the case when a filter supports multiple |
|
31 |
+ * formats, but will always output the same format as it is given in input. |
|
32 |
+ * |
|
33 |
+ * In this way, a list of possible input formats and a list of possible |
|
34 |
+ * output formats are associated with each link. When a set of formats is |
|
35 |
+ * negotiated over a link, the input and output lists are merged to form a |
|
36 |
+ * new list containing only the common elements of each list. In the case |
|
37 |
+ * that there were no common elements, a format conversion is necessary. |
|
38 |
+ * Otherwise, the lists are merged, and all other links which reference |
|
39 |
+ * either of the format lists involved in the merge are also affected. |
|
40 |
+ * |
|
41 |
+ * For example, consider the filter chain: |
|
42 |
+ * filter (a) --> (b) filter (b) --> (c) filter |
|
43 |
+ * |
|
44 |
+ * where the letters in parenthesis indicate a list of formats supported on |
|
45 |
+ * the input or output of the link. Suppose the lists are as follows: |
|
46 |
+ * (a) = {A, B} |
|
47 |
+ * (b) = {A, B, C} |
|
48 |
+ * (c) = {B, C} |
|
49 |
+ * |
|
50 |
+ * First, the first link's lists are merged, yielding: |
|
51 |
+ * filter (a) --> (a) filter (a) --> (c) filter |
|
52 |
+ * |
|
53 |
+ * Notice that format list (b) now refers to the same list as filter list (a). |
|
54 |
+ * Next, the lists for the second link are merged, yielding: |
|
55 |
+ * filter (a) --> (a) filter (a) --> (a) filter |
|
56 |
+ * |
|
57 |
+ * where (a) = {B}. |
|
58 |
+ * |
|
59 |
+ * Unfortunately, when the format lists at the two ends of a link are merged, |
|
60 |
+ * we must ensure that all links which reference either pre-merge format list |
|
61 |
+ * get updated as well. Therefore, we have the format list structure store a |
|
62 |
+ * pointer to each of the pointers to itself. |
|
63 |
+ */ |
|
64 |
+#if !FF_API_FILTERS_PUBLIC |
|
65 |
+struct AVFilterFormats { |
|
66 |
+ unsigned format_count; ///< number of formats |
|
67 |
+ int *formats; ///< list of media formats |
|
68 |
+ |
|
69 |
+ unsigned refcount; ///< number of references to this list |
|
70 |
+ struct AVFilterFormats ***refs; ///< references to this list |
|
71 |
+}; |
|
72 |
+#endif |
|
73 |
+ |
|
24 | 74 |
typedef struct AVFilterChannelLayouts { |
25 | 75 |
uint64_t *channel_layouts; ///< list of channel layouts |
26 | 76 |
int nb_channel_layouts; ///< number of channel layouts |
... | ... |
@@ -62,6 +112,13 @@ void ff_set_common_channel_layouts(AVFilterContext *ctx, |
62 | 62 |
void ff_set_common_samplerates(AVFilterContext *ctx, |
63 | 63 |
AVFilterFormats *samplerates); |
64 | 64 |
|
65 |
+/** |
|
66 |
+ * A helper for query_formats() which sets all links to the same list of |
|
67 |
+ * formats. If there are no links hooked to this filter, the list of formats is |
|
68 |
+ * freed. |
|
69 |
+ */ |
|
70 |
+void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); |
|
71 |
+ |
|
65 | 72 |
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout); |
66 | 73 |
|
67 | 74 |
/** |
... | ... |
@@ -80,4 +137,85 @@ void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, |
80 | 80 |
|
81 | 81 |
int ff_default_query_formats(AVFilterContext *ctx); |
82 | 82 |
|
83 |
+ |
|
84 |
+/** |
|
85 |
+ * Create a list of supported formats. This is intended for use in |
|
86 |
+ * AVFilter->query_formats(). |
|
87 |
+ * |
|
88 |
+ * @param fmts list of media formats, terminated by -1 |
|
89 |
+ * @return the format list, with no existing references |
|
90 |
+ */ |
|
91 |
+AVFilterFormats *ff_make_format_list(const int *fmts); |
|
92 |
+ |
|
93 |
+/** |
|
94 |
+ * Add fmt to the list of media formats contained in *avff. |
|
95 |
+ * If *avff is NULL the function allocates the filter formats struct |
|
96 |
+ * and puts its pointer in *avff. |
|
97 |
+ * |
|
98 |
+ * @return a non negative value in case of success, or a negative |
|
99 |
+ * value corresponding to an AVERROR code in case of error |
|
100 |
+ */ |
|
101 |
+int ff_add_format(AVFilterFormats **avff, int64_t fmt); |
|
102 |
+ |
|
103 |
+/** |
|
104 |
+ * Return a list of all formats supported by Libav for the given media type. |
|
105 |
+ */ |
|
106 |
+AVFilterFormats *ff_all_formats(enum AVMediaType type); |
|
107 |
+ |
|
108 |
+/** |
|
109 |
+ * Return a format list which contains the intersection of the formats of |
|
110 |
+ * a and b. Also, all the references of a, all the references of b, and |
|
111 |
+ * a and b themselves will be deallocated. |
|
112 |
+ * |
|
113 |
+ * If a and b do not share any common formats, neither is modified, and NULL |
|
114 |
+ * is returned. |
|
115 |
+ */ |
|
116 |
+AVFilterFormats *ff_merge_formats(AVFilterFormats *a, AVFilterFormats *b); |
|
117 |
+ |
|
118 |
+/** |
|
119 |
+ * Add *ref as a new reference to formats. |
|
120 |
+ * That is the pointers will point like in the ascii art below: |
|
121 |
+ * ________ |
|
122 |
+ * |formats |<--------. |
|
123 |
+ * | ____ | ____|___________________ |
|
124 |
+ * | |refs| | | __|_ |
|
125 |
+ * | |* * | | | | | | AVFilterLink |
|
126 |
+ * | |* *--------->|*ref| |
|
127 |
+ * | |____| | | |____| |
|
128 |
+ * |________| |________________________ |
|
129 |
+ */ |
|
130 |
+void ff_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref); |
|
131 |
+ |
|
132 |
+/** |
|
133 |
+ * If *ref is non-NULL, remove *ref as a reference to the format list |
|
134 |
+ * it currently points to, deallocates that list if this was the last |
|
135 |
+ * reference, and sets *ref to NULL. |
|
136 |
+ * |
|
137 |
+ * Before After |
|
138 |
+ * ________ ________ NULL |
|
139 |
+ * |formats |<--------. |formats | ^ |
|
140 |
+ * | ____ | ____|________________ | ____ | ____|________________ |
|
141 |
+ * | |refs| | | __|_ | |refs| | | __|_ |
|
142 |
+ * | |* * | | | | | | AVFilterLink | |* * | | | | | | AVFilterLink |
|
143 |
+ * | |* *--------->|*ref| | |* | | | |*ref| |
|
144 |
+ * | |____| | | |____| | |____| | | |____| |
|
145 |
+ * |________| |_____________________ |________| |_____________________ |
|
146 |
+ */ |
|
147 |
+void ff_formats_unref(AVFilterFormats **ref); |
|
148 |
+ |
|
149 |
+/** |
|
150 |
+ * |
|
151 |
+ * Before After |
|
152 |
+ * ________ ________ |
|
153 |
+ * |formats |<---------. |formats |<---------. |
|
154 |
+ * | ____ | ___|___ | ____ | ___|___ |
|
155 |
+ * | |refs| | | | | | |refs| | | | | NULL |
|
156 |
+ * | |* *--------->|*oldref| | |* *--------->|*newref| ^ |
|
157 |
+ * | |* * | | |_______| | |* * | | |_______| ___|___ |
|
158 |
+ * | |____| | | |____| | | | | |
|
159 |
+ * |________| |________| |*oldref| |
|
160 |
+ * |_______| |
|
161 |
+ */ |
|
162 |
+void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref); |
|
163 |
+ |
|
83 | 164 |
#endif // AVFILTER_FORMATS_H |
... | ... |
@@ -144,4 +144,54 @@ void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end); |
144 | 144 |
|
145 | 145 |
void ff_dlog_link(void *ctx, AVFilterLink *link, int end); |
146 | 146 |
|
147 |
+/** |
|
148 |
+ * Insert a new pad. |
|
149 |
+ * |
|
150 |
+ * @param idx Insertion point. Pad is inserted at the end if this point |
|
151 |
+ * is beyond the end of the list of pads. |
|
152 |
+ * @param count Pointer to the number of pads in the list |
|
153 |
+ * @param padidx_off Offset within an AVFilterLink structure to the element |
|
154 |
+ * to increment when inserting a new pad causes link |
|
155 |
+ * numbering to change |
|
156 |
+ * @param pads Pointer to the pointer to the beginning of the list of pads |
|
157 |
+ * @param links Pointer to the pointer to the beginning of the list of links |
|
158 |
+ * @param newpad The new pad to add. A copy is made when adding. |
|
159 |
+ */ |
|
160 |
+void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, |
|
161 |
+ AVFilterPad **pads, AVFilterLink ***links, |
|
162 |
+ AVFilterPad *newpad); |
|
163 |
+ |
|
164 |
+/** Insert a new input pad for the filter. */ |
|
165 |
+static inline void ff_insert_inpad(AVFilterContext *f, unsigned index, |
|
166 |
+ AVFilterPad *p) |
|
167 |
+{ |
|
168 |
+ ff_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad), |
|
169 |
+ &f->input_pads, &f->inputs, p); |
|
170 |
+} |
|
171 |
+ |
|
172 |
+/** Insert a new output pad for the filter. */ |
|
173 |
+static inline void ff_insert_outpad(AVFilterContext *f, unsigned index, |
|
174 |
+ AVFilterPad *p) |
|
175 |
+{ |
|
176 |
+ ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad), |
|
177 |
+ &f->output_pads, &f->outputs, p); |
|
178 |
+} |
|
179 |
+ |
|
180 |
+/** |
|
181 |
+ * Poll a frame from the filter chain. |
|
182 |
+ * |
|
183 |
+ * @param link the input link |
|
184 |
+ * @return the number of immediately available frames, a negative |
|
185 |
+ * number in case of error |
|
186 |
+ */ |
|
187 |
+int ff_poll_frame(AVFilterLink *link); |
|
188 |
+ |
|
189 |
+/** |
|
190 |
+ * Request an input frame from the filter at the other end of the link. |
|
191 |
+ * |
|
192 |
+ * @param link the input link |
|
193 |
+ * @return zero on success |
|
194 |
+ */ |
|
195 |
+int ff_request_frame(AVFilterLink *link); |
|
196 |
+ |
|
147 | 197 |
#endif /* AVFILTER_INTERNAL_H */ |
... | ... |
@@ -25,6 +25,7 @@ |
25 | 25 |
|
26 | 26 |
#include "avfilter.h" |
27 | 27 |
#include "audio.h" |
28 |
+#include "internal.h" |
|
28 | 29 |
#include "video.h" |
29 | 30 |
|
30 | 31 |
static int split_init(AVFilterContext *ctx, const char *args, void *opaque) |
... | ... |
@@ -48,7 +49,7 @@ static int split_init(AVFilterContext *ctx, const char *args, void *opaque) |
48 | 48 |
pad.type = ctx->filter->inputs[0].type; |
49 | 49 |
pad.name = av_strdup(name); |
50 | 50 |
|
51 |
- avfilter_insert_outpad(ctx, i, &pad); |
|
51 |
+ ff_insert_outpad(ctx, i, &pad); |
|
52 | 52 |
} |
53 | 53 |
|
54 | 54 |
return 0; |
... | ... |
@@ -68,8 +69,8 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
68 | 68 |
int i; |
69 | 69 |
|
70 | 70 |
for (i = 0; i < ctx->output_count; i++) |
71 |
- avfilter_start_frame(ctx->outputs[i], |
|
72 |
- avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); |
|
71 |
+ ff_start_frame(ctx->outputs[i], |
|
72 |
+ avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); |
|
73 | 73 |
} |
74 | 74 |
|
75 | 75 |
static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
... | ... |
@@ -78,7 +79,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
78 | 78 |
int i; |
79 | 79 |
|
80 | 80 |
for (i = 0; i < ctx->output_count; i++) |
81 |
- avfilter_draw_slice(ctx->outputs[i], y, h, slice_dir); |
|
81 |
+ ff_draw_slice(ctx->outputs[i], y, h, slice_dir); |
|
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
static void end_frame(AVFilterLink *inlink) |
... | ... |
@@ -87,7 +88,7 @@ static void end_frame(AVFilterLink *inlink) |
87 | 87 |
int i; |
88 | 88 |
|
89 | 89 |
for (i = 0; i < ctx->output_count; i++) |
90 |
- avfilter_end_frame(ctx->outputs[i]); |
|
90 |
+ ff_end_frame(ctx->outputs[i]); |
|
91 | 91 |
|
92 | 92 |
avfilter_unref_buffer(inlink->cur_buf); |
93 | 93 |
} |
... | ... |
@@ -39,6 +39,7 @@ |
39 | 39 |
#include "avcodec.h" |
40 | 40 |
#include "avfilter.h" |
41 | 41 |
#include "formats.h" |
42 |
+#include "video.h" |
|
42 | 43 |
|
43 | 44 |
typedef struct { |
44 | 45 |
/* common A/V fields */ |
... | ... |
@@ -219,7 +220,7 @@ static int movie_query_formats(AVFilterContext *ctx) |
219 | 219 |
MovieContext *movie = ctx->priv; |
220 | 220 |
enum PixelFormat pix_fmts[] = { movie->codec_ctx->pix_fmt, PIX_FMT_NONE }; |
221 | 221 |
|
222 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
222 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
223 | 223 |
return 0; |
224 | 224 |
} |
225 | 225 |
|
... | ... |
@@ -318,9 +319,9 @@ static int movie_request_frame(AVFilterLink *outlink) |
318 | 318 |
return ret; |
319 | 319 |
|
320 | 320 |
outpicref = avfilter_ref_buffer(movie->picref, ~0); |
321 |
- avfilter_start_frame(outlink, outpicref); |
|
322 |
- avfilter_draw_slice(outlink, 0, outlink->h, 1); |
|
323 |
- avfilter_end_frame(outlink); |
|
321 |
+ ff_start_frame(outlink, outpicref); |
|
322 |
+ ff_draw_slice(outlink, 0, outlink->h, 1); |
|
323 |
+ ff_end_frame(outlink); |
|
324 | 324 |
avfilter_unref_buffer(movie->picref); |
325 | 325 |
movie->picref = NULL; |
326 | 326 |
|
... | ... |
@@ -55,7 +55,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
55 | 55 |
AspectContext *aspect = link->dst->priv; |
56 | 56 |
|
57 | 57 |
picref->video->sample_aspect_ratio = aspect->ratio; |
58 |
- avfilter_start_frame(link->dst->outputs[0], picref); |
|
58 |
+ ff_start_frame(link->dst->outputs[0], picref); |
|
59 | 59 |
} |
60 | 60 |
|
61 | 61 |
#if CONFIG_SETDAR_FILTER |
... | ... |
@@ -29,6 +29,7 @@ |
29 | 29 |
|
30 | 30 |
#include "avfilter.h" |
31 | 31 |
#include "internal.h" |
32 |
+#include "formats.h" |
|
32 | 33 |
#include "video.h" |
33 | 34 |
|
34 | 35 |
typedef struct { |
... | ... |
@@ -47,7 +48,7 @@ static int query_formats(AVFilterContext *ctx) |
47 | 47 |
PIX_FMT_NONE |
48 | 48 |
}; |
49 | 49 |
|
50 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
50 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
51 | 51 |
return 0; |
52 | 52 |
} |
53 | 53 |
|
... | ... |
@@ -89,7 +90,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
89 | 89 |
p += picref->linesize[0]; |
90 | 90 |
} |
91 | 91 |
|
92 |
- avfilter_draw_slice(ctx->outputs[0], y, h, slice_dir); |
|
92 |
+ ff_draw_slice(ctx->outputs[0], y, h, slice_dir); |
|
93 | 93 |
} |
94 | 94 |
|
95 | 95 |
static void end_frame(AVFilterLink *inlink) |
... | ... |
@@ -113,7 +114,7 @@ static void end_frame(AVFilterLink *inlink) |
113 | 113 |
blackframe->frame++; |
114 | 114 |
blackframe->nblack = 0; |
115 | 115 |
avfilter_unref_buffer(picref); |
116 |
- avfilter_end_frame(inlink->dst->outputs[0]); |
|
116 |
+ ff_end_frame(inlink->dst->outputs[0]); |
|
117 | 117 |
} |
118 | 118 |
|
119 | 119 |
AVFilter avfilter_vf_blackframe = { |
... | ... |
@@ -29,6 +29,8 @@ |
29 | 29 |
#include "libavutil/eval.h" |
30 | 30 |
#include "libavutil/pixdesc.h" |
31 | 31 |
#include "avfilter.h" |
32 |
+#include "formats.h" |
|
33 |
+#include "video.h" |
|
32 | 34 |
|
33 | 35 |
static const char *const var_names[] = { |
34 | 36 |
"w", |
... | ... |
@@ -129,7 +131,7 @@ static int query_formats(AVFilterContext *ctx) |
129 | 129 |
PIX_FMT_NONE |
130 | 130 |
}; |
131 | 131 |
|
132 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
132 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
133 | 133 |
return 0; |
134 | 134 |
} |
135 | 135 |
|
... | ... |
@@ -324,7 +326,7 @@ static void end_frame(AVFilterLink *inlink) |
324 | 324 |
w[plane], h[plane], boxblur->radius[plane], boxblur->power[plane], |
325 | 325 |
boxblur->temp); |
326 | 326 |
|
327 |
- avfilter_draw_slice(outlink, 0, inlink->h, 1); |
|
327 |
+ ff_draw_slice(outlink, 0, inlink->h, 1); |
|
328 | 328 |
avfilter_default_end_frame(inlink); |
329 | 329 |
} |
330 | 330 |
|
... | ... |
@@ -26,6 +26,7 @@ |
26 | 26 |
/* #define DEBUG */ |
27 | 27 |
|
28 | 28 |
#include "avfilter.h" |
29 |
+#include "formats.h" |
|
29 | 30 |
#include "video.h" |
30 | 31 |
#include "libavutil/eval.h" |
31 | 32 |
#include "libavutil/avstring.h" |
... | ... |
@@ -113,7 +114,7 @@ static int query_formats(AVFilterContext *ctx) |
113 | 113 |
PIX_FMT_NONE |
114 | 114 |
}; |
115 | 115 |
|
116 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
116 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
117 | 117 |
|
118 | 118 |
return 0; |
119 | 119 |
} |
... | ... |
@@ -308,7 +309,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
308 | 308 |
ref2->data[3] += crop->x * crop->max_step[3]; |
309 | 309 |
} |
310 | 310 |
|
311 |
- avfilter_start_frame(link->dst->outputs[0], ref2); |
|
311 |
+ ff_start_frame(link->dst->outputs[0], ref2); |
|
312 | 312 |
} |
313 | 313 |
|
314 | 314 |
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
... | ... |
@@ -326,7 +327,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
326 | 326 |
if (y + h > crop->y + crop->h) |
327 | 327 |
h = crop->y + crop->h - y; |
328 | 328 |
|
329 |
- avfilter_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir); |
|
329 |
+ ff_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir); |
|
330 | 330 |
} |
331 | 331 |
|
332 | 332 |
static void end_frame(AVFilterLink *link) |
... | ... |
@@ -335,7 +336,7 @@ static void end_frame(AVFilterLink *link) |
335 | 335 |
|
336 | 336 |
crop->var_values[VAR_N] += 1.0; |
337 | 337 |
avfilter_unref_buffer(link->cur_buf); |
338 |
- avfilter_end_frame(link->dst->outputs[0]); |
|
338 |
+ ff_end_frame(link->dst->outputs[0]); |
|
339 | 339 |
} |
340 | 340 |
|
341 | 341 |
AVFilter avfilter_vf_crop = { |
... | ... |
@@ -25,6 +25,7 @@ |
25 | 25 |
|
26 | 26 |
#include "libavutil/imgutils.h" |
27 | 27 |
#include "avfilter.h" |
28 |
+#include "formats.h" |
|
28 | 29 |
#include "video.h" |
29 | 30 |
|
30 | 31 |
typedef struct { |
... | ... |
@@ -47,7 +48,7 @@ static int query_formats(AVFilterContext *ctx) |
47 | 47 |
PIX_FMT_NONE |
48 | 48 |
}; |
49 | 49 |
|
50 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
50 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
51 | 51 |
return 0; |
52 | 52 |
} |
53 | 53 |
|
... | ... |
@@ -189,7 +190,7 @@ static void end_frame(AVFilterLink *inlink) |
189 | 189 |
w, h, x, y); |
190 | 190 |
} |
191 | 191 |
|
192 |
- avfilter_end_frame(inlink->dst->outputs[0]); |
|
192 |
+ ff_end_frame(inlink->dst->outputs[0]); |
|
193 | 193 |
} |
194 | 194 |
|
195 | 195 |
AVFilter avfilter_vf_cropdetect = { |
... | ... |
@@ -29,6 +29,7 @@ |
29 | 29 |
#include "libavutil/opt.h" |
30 | 30 |
#include "libavutil/pixdesc.h" |
31 | 31 |
#include "avfilter.h" |
32 |
+#include "formats.h" |
|
32 | 33 |
#include "video.h" |
33 | 34 |
|
34 | 35 |
/** |
... | ... |
@@ -164,7 +165,7 @@ static int query_formats(AVFilterContext *ctx) |
164 | 164 |
PIX_FMT_NONE |
165 | 165 |
}; |
166 | 166 |
|
167 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
167 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
168 | 168 |
return 0; |
169 | 169 |
} |
170 | 170 |
|
... | ... |
@@ -226,7 +227,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
226 | 226 |
outpicref = inpicref; |
227 | 227 |
|
228 | 228 |
outlink->out_buf = outpicref; |
229 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); |
|
229 |
+ ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); |
|
230 | 230 |
} |
231 | 231 |
|
232 | 232 |
static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } |
... | ... |
@@ -255,8 +256,8 @@ static void end_frame(AVFilterLink *inlink) |
255 | 255 |
delogo->show, direct); |
256 | 256 |
} |
257 | 257 |
|
258 |
- avfilter_draw_slice(outlink, 0, inlink->h, 1); |
|
259 |
- avfilter_end_frame(outlink); |
|
258 |
+ ff_draw_slice(outlink, 0, inlink->h, 1); |
|
259 |
+ ff_end_frame(outlink); |
|
260 | 260 |
avfilter_unref_buffer(inpicref); |
261 | 261 |
if (!direct) |
262 | 262 |
avfilter_unref_buffer(outpicref); |
... | ... |
@@ -28,6 +28,7 @@ |
28 | 28 |
#include "libavutil/pixdesc.h" |
29 | 29 |
#include "libavutil/parseutils.h" |
30 | 30 |
#include "avfilter.h" |
31 |
+#include "formats.h" |
|
31 | 32 |
#include "video.h" |
32 | 33 |
|
33 | 34 |
enum { Y, U, V, A }; |
... | ... |
@@ -71,7 +72,7 @@ static int query_formats(AVFilterContext *ctx) |
71 | 71 |
PIX_FMT_NONE |
72 | 72 |
}; |
73 | 73 |
|
74 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
74 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
75 | 75 |
return 0; |
76 | 76 |
} |
77 | 77 |
|
... | ... |
@@ -118,7 +119,7 @@ static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir) |
118 | 118 |
} |
119 | 119 |
} |
120 | 120 |
|
121 |
- avfilter_draw_slice(inlink->dst->outputs[0], y0, h, 1); |
|
121 |
+ ff_draw_slice(inlink->dst->outputs[0], y0, h, 1); |
|
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
AVFilter avfilter_vf_drawbox = { |
... | ... |
@@ -41,6 +41,7 @@ |
41 | 41 |
#include "libavutil/lfg.h" |
42 | 42 |
#include "avfilter.h" |
43 | 43 |
#include "drawutils.h" |
44 |
+#include "formats.h" |
|
44 | 45 |
#include "video.h" |
45 | 46 |
|
46 | 47 |
#undef time |
... | ... |
@@ -492,7 +493,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) |
492 | 492 |
|
493 | 493 |
static int query_formats(AVFilterContext *ctx) |
494 | 494 |
{ |
495 |
- avfilter_set_common_pixel_formats(ctx, ff_draw_supported_pixel_formats(0)); |
|
495 |
+ ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0)); |
|
496 | 496 |
return 0; |
497 | 497 |
} |
498 | 498 |
|
... | ... |
@@ -812,8 +813,8 @@ static void end_frame(AVFilterLink *inlink) |
812 | 812 |
|
813 | 813 |
dtext->var_values[VAR_N] += 1.0; |
814 | 814 |
|
815 |
- avfilter_draw_slice(outlink, 0, picref->video->h, 1); |
|
816 |
- avfilter_end_frame(outlink); |
|
815 |
+ ff_draw_slice(outlink, 0, picref->video->h, 1); |
|
816 |
+ ff_end_frame(outlink); |
|
817 | 817 |
} |
818 | 818 |
|
819 | 819 |
AVFilter avfilter_vf_drawtext = { |
... | ... |
@@ -32,6 +32,7 @@ |
32 | 32 |
#include "avfilter.h" |
33 | 33 |
#include "drawutils.h" |
34 | 34 |
#include "internal.h" |
35 |
+#include "formats.h" |
|
35 | 36 |
#include "video.h" |
36 | 37 |
|
37 | 38 |
#define R 0 |
... | ... |
@@ -158,7 +159,7 @@ static int query_formats(AVFilterContext *ctx) |
158 | 158 |
PIX_FMT_NONE |
159 | 159 |
}; |
160 | 160 |
|
161 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
161 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
162 | 162 |
return 0; |
163 | 163 |
} |
164 | 164 |
|
... | ... |
@@ -257,14 +258,14 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
257 | 257 |
} |
258 | 258 |
} |
259 | 259 |
|
260 |
- avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
|
260 |
+ ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
|
261 | 261 |
} |
262 | 262 |
|
263 | 263 |
static void end_frame(AVFilterLink *inlink) |
264 | 264 |
{ |
265 | 265 |
FadeContext *fade = inlink->dst->priv; |
266 | 266 |
|
267 |
- avfilter_end_frame(inlink->dst->outputs[0]); |
|
267 |
+ ff_end_frame(inlink->dst->outputs[0]); |
|
268 | 268 |
|
269 | 269 |
if (fade->frame_index >= fade->start_frame && |
270 | 270 |
fade->frame_index <= fade->stop_frame) |
... | ... |
@@ -28,6 +28,8 @@ |
28 | 28 |
#include "libavutil/imgutils.h" |
29 | 29 |
#include "libavutil/pixdesc.h" |
30 | 30 |
#include "avfilter.h" |
31 |
+#include "formats.h" |
|
32 |
+#include "video.h" |
|
31 | 33 |
|
32 | 34 |
typedef struct |
33 | 35 |
{ |
... | ... |
@@ -76,12 +78,12 @@ static int query_formats(AVFilterContext *ctx) |
76 | 76 |
|| av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_BITSTREAM) |
77 | 77 |
&& av_pix_fmt_descriptors[pix_fmt].nb_components |
78 | 78 |
&& !av_pix_fmt_descriptors[pix_fmt].log2_chroma_h |
79 |
- && (ret = avfilter_add_format(&formats, pix_fmt)) < 0) { |
|
80 |
- avfilter_formats_unref(&formats); |
|
79 |
+ && (ret = ff_add_format(&formats, pix_fmt)) < 0) { |
|
80 |
+ ff_formats_unref(&formats); |
|
81 | 81 |
return ret; |
82 | 82 |
} |
83 |
- avfilter_formats_ref(formats, &ctx->inputs[0]->out_formats); |
|
84 |
- avfilter_formats_ref(formats, &ctx->outputs[0]->in_formats); |
|
83 |
+ ff_formats_ref(formats, &ctx->inputs[0]->out_formats); |
|
84 |
+ ff_formats_ref(formats, &ctx->outputs[0]->in_formats); |
|
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
return 0; |
... | ... |
@@ -123,7 +125,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
123 | 123 |
outpicref = avfilter_ref_buffer(inpicref, ~0); |
124 | 124 |
outlink->out_buf = outpicref; |
125 | 125 |
|
126 |
- avfilter_start_frame(outlink, outpicref); |
|
126 |
+ ff_start_frame(outlink, outpicref); |
|
127 | 127 |
} |
128 | 128 |
|
129 | 129 |
static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
... | ... |
@@ -140,7 +142,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
140 | 140 |
* and that complexity will be added later */ |
141 | 141 |
if ( !inpicref->video->interlaced |
142 | 142 |
|| inpicref->video->top_field_first == fieldorder->dst_tff) { |
143 |
- avfilter_draw_slice(outlink, y, h, slice_dir); |
|
143 |
+ ff_draw_slice(outlink, y, h, slice_dir); |
|
144 | 144 |
} |
145 | 145 |
} |
146 | 146 |
|
... | ... |
@@ -202,13 +204,13 @@ static void end_frame(AVFilterLink *inlink) |
202 | 202 |
} |
203 | 203 |
} |
204 | 204 |
outpicref->video->top_field_first = fieldorder->dst_tff; |
205 |
- avfilter_draw_slice(outlink, 0, h, 1); |
|
205 |
+ ff_draw_slice(outlink, 0, h, 1); |
|
206 | 206 |
} else { |
207 | 207 |
av_dlog(ctx, |
208 | 208 |
"not interlaced or field order already correct\n"); |
209 | 209 |
} |
210 | 210 |
|
211 |
- avfilter_end_frame(outlink); |
|
211 |
+ ff_end_frame(outlink); |
|
212 | 212 |
avfilter_unref_buffer(inpicref); |
213 | 213 |
} |
214 | 214 |
|
... | ... |
@@ -24,6 +24,7 @@ |
24 | 24 |
*/ |
25 | 25 |
|
26 | 26 |
#include "avfilter.h" |
27 |
+#include "internal.h" |
|
27 | 28 |
#include "video.h" |
28 | 29 |
|
29 | 30 |
typedef struct BufPic { |
... | ... |
@@ -83,9 +84,9 @@ static int request_frame(AVFilterLink *outlink) |
83 | 83 |
|
84 | 84 |
/* by doing this, we give ownership of the reference to the next filter, |
85 | 85 |
* so we don't have to worry about dereferencing it ourselves. */ |
86 |
- avfilter_start_frame(outlink, fifo->root.next->picref); |
|
87 |
- avfilter_draw_slice (outlink, 0, outlink->h, 1); |
|
88 |
- avfilter_end_frame (outlink); |
|
86 |
+ ff_start_frame(outlink, fifo->root.next->picref); |
|
87 |
+ ff_draw_slice (outlink, 0, outlink->h, 1); |
|
88 |
+ ff_end_frame (outlink); |
|
89 | 89 |
|
90 | 90 |
if (fifo->last == fifo->root.next) |
91 | 91 |
fifo->last = &fifo->root; |
... | ... |
@@ -26,6 +26,7 @@ |
26 | 26 |
#include "libavutil/pixdesc.h" |
27 | 27 |
#include "avfilter.h" |
28 | 28 |
#include "internal.h" |
29 |
+#include "formats.h" |
|
29 | 30 |
#include "video.h" |
30 | 31 |
|
31 | 32 |
typedef struct { |
... | ... |
@@ -87,7 +88,7 @@ static AVFilterFormats *make_format_list(FormatContext *format, int flag) |
87 | 87 |
#if CONFIG_FORMAT_FILTER |
88 | 88 |
static int query_formats_format(AVFilterContext *ctx) |
89 | 89 |
{ |
90 |
- avfilter_set_common_pixel_formats(ctx, make_format_list(ctx->priv, 1)); |
|
90 |
+ ff_set_common_formats(ctx, make_format_list(ctx->priv, 1)); |
|
91 | 91 |
return 0; |
92 | 92 |
} |
93 | 93 |
|
... | ... |
@@ -117,7 +118,7 @@ AVFilter avfilter_vf_format = { |
117 | 117 |
#if CONFIG_NOFORMAT_FILTER |
118 | 118 |
static int query_formats_noformat(AVFilterContext *ctx) |
119 | 119 |
{ |
120 |
- avfilter_set_common_pixel_formats(ctx, make_format_list(ctx->priv, 0)); |
|
120 |
+ ff_set_common_formats(ctx, make_format_list(ctx->priv, 0)); |
|
121 | 121 |
return 0; |
122 | 122 |
} |
123 | 123 |
|
... | ... |
@@ -31,6 +31,8 @@ |
31 | 31 |
#include "libavutil/parseutils.h" |
32 | 32 |
|
33 | 33 |
#include "avfilter.h" |
34 |
+#include "internal.h" |
|
35 |
+#include "video.h" |
|
34 | 36 |
|
35 | 37 |
typedef struct FPSContext { |
36 | 38 |
const AVClass *class; |
... | ... |
@@ -133,7 +135,7 @@ static int request_frame(AVFilterLink *outlink) |
133 | 133 |
int ret = 0; |
134 | 134 |
|
135 | 135 |
while (ret >= 0 && s->frames_out == frames_out) |
136 |
- ret = avfilter_request_frame(ctx->inputs[0]); |
|
136 |
+ ret = ff_request_frame(ctx->inputs[0]); |
|
137 | 137 |
|
138 | 138 |
/* flush the fifo */ |
139 | 139 |
if (ret == AVERROR_EOF && av_fifo_size(s->fifo)) { |
... | ... |
@@ -145,9 +147,9 @@ static int request_frame(AVFilterLink *outlink) |
145 | 145 |
buf->pts = av_rescale_q(s->first_pts, ctx->inputs[0]->time_base, |
146 | 146 |
outlink->time_base) + s->frames_out; |
147 | 147 |
|
148 |
- avfilter_start_frame(outlink, buf); |
|
149 |
- avfilter_draw_slice(outlink, 0, outlink->h, 1); |
|
150 |
- avfilter_end_frame(outlink); |
|
148 |
+ ff_start_frame(outlink, buf); |
|
149 |
+ ff_draw_slice(outlink, 0, outlink->h, 1); |
|
150 |
+ ff_end_frame(outlink); |
|
151 | 151 |
s->frames_out++; |
152 | 152 |
} |
153 | 153 |
return 0; |
... | ... |
@@ -233,9 +235,9 @@ static void end_frame(AVFilterLink *inlink) |
233 | 233 |
buf_out->pts = av_rescale_q(s->first_pts, inlink->time_base, |
234 | 234 |
outlink->time_base) + s->frames_out; |
235 | 235 |
|
236 |
- avfilter_start_frame(outlink, buf_out); |
|
237 |
- avfilter_draw_slice(outlink, 0, outlink->h, 1); |
|
238 |
- avfilter_end_frame(outlink); |
|
236 |
+ ff_start_frame(outlink, buf_out); |
|
237 |
+ ff_draw_slice(outlink, 0, outlink->h, 1); |
|
238 |
+ ff_end_frame(outlink); |
|
239 | 239 |
s->frames_out++; |
240 | 240 |
} |
241 | 241 |
flush_fifo(s->fifo); |
... | ... |
@@ -31,6 +31,8 @@ |
31 | 31 |
#include "libavutil/mathematics.h" |
32 | 32 |
#include "libavutil/parseutils.h" |
33 | 33 |
#include "avfilter.h" |
34 |
+#include "formats.h" |
|
35 |
+#include "video.h" |
|
34 | 36 |
|
35 | 37 |
typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height); |
36 | 38 |
typedef void (*f0r_destruct_f)(f0r_instance_t instance); |
... | ... |
@@ -320,20 +322,20 @@ static int query_formats(AVFilterContext *ctx) |
320 | 320 |
AVFilterFormats *formats = NULL; |
321 | 321 |
|
322 | 322 |
if (frei0r->plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) { |
323 |
- avfilter_add_format(&formats, PIX_FMT_BGRA); |
|
323 |
+ ff_add_format(&formats, PIX_FMT_BGRA); |
|
324 | 324 |
} else if (frei0r->plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) { |
325 |
- avfilter_add_format(&formats, PIX_FMT_RGBA); |
|
325 |
+ ff_add_format(&formats, PIX_FMT_RGBA); |
|
326 | 326 |
} else { /* F0R_COLOR_MODEL_PACKED32 */ |
327 | 327 |
static const enum PixelFormat pix_fmts[] = { |
328 | 328 |
PIX_FMT_BGRA, PIX_FMT_ARGB, PIX_FMT_ABGR, PIX_FMT_ARGB, PIX_FMT_NONE |
329 | 329 |
}; |
330 |
- formats = avfilter_make_format_list(pix_fmts); |
|
330 |
+ formats = ff_make_format_list(pix_fmts); |
|
331 | 331 |
} |
332 | 332 |
|
333 | 333 |
if (!formats) |
334 | 334 |
return AVERROR(ENOMEM); |
335 | 335 |
|
336 |
- avfilter_set_common_pixel_formats(ctx, formats); |
|
336 |
+ ff_set_common_formats(ctx, formats); |
|
337 | 337 |
return 0; |
338 | 338 |
} |
339 | 339 |
|
... | ... |
@@ -350,8 +352,8 @@ static void end_frame(AVFilterLink *inlink) |
350 | 350 |
(const uint32_t *)inpicref->data[0], |
351 | 351 |
(uint32_t *)outpicref->data[0]); |
352 | 352 |
avfilter_unref_buffer(inpicref); |
353 |
- avfilter_draw_slice(outlink, 0, outlink->h, 1); |
|
354 |
- avfilter_end_frame(outlink); |
|
353 |
+ ff_draw_slice(outlink, 0, outlink->h, 1); |
|
354 |
+ ff_end_frame(outlink); |
|
355 | 355 |
avfilter_unref_buffer(outpicref); |
356 | 356 |
} |
357 | 357 |
|
... | ... |
@@ -436,11 +438,11 @@ static int source_request_frame(AVFilterLink *outlink) |
436 | 436 |
picref->pts = frei0r->pts++; |
437 | 437 |
picref->pos = -1; |
438 | 438 |
|
439 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); |
|
439 |
+ ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); |
|
440 | 440 |
frei0r->update(frei0r->instance, av_rescale_q(picref->pts, frei0r->time_base, (AVRational){1,1000}), |
441 | 441 |
NULL, (uint32_t *)picref->data[0]); |
442 |
- avfilter_draw_slice(outlink, 0, outlink->h, 1); |
|
443 |
- avfilter_end_frame(outlink); |
|
442 |
+ ff_draw_slice(outlink, 0, outlink->h, 1); |
|
443 |
+ ff_end_frame(outlink); |
|
444 | 444 |
avfilter_unref_buffer(picref); |
445 | 445 |
|
446 | 446 |
return 0; |
... | ... |
@@ -36,7 +36,9 @@ |
36 | 36 |
#include "libavutil/cpu.h" |
37 | 37 |
#include "libavutil/pixdesc.h" |
38 | 38 |
#include "avfilter.h" |
39 |
+#include "formats.h" |
|
39 | 40 |
#include "gradfun.h" |
41 |
+#include "video.h" |
|
40 | 42 |
|
41 | 43 |
DECLARE_ALIGNED(16, static const uint16_t, dither)[8][8] = { |
42 | 44 |
{0x00,0x60,0x18,0x78,0x06,0x66,0x1E,0x7E}, |
... | ... |
@@ -160,7 +162,7 @@ static int query_formats(AVFilterContext *ctx) |
160 | 160 |
PIX_FMT_NONE |
161 | 161 |
}; |
162 | 162 |
|
163 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
163 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
164 | 164 |
|
165 | 165 |
return 0; |
166 | 166 |
} |
... | ... |
@@ -196,7 +198,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
196 | 196 |
outpicref = inpicref; |
197 | 197 |
|
198 | 198 |
outlink->out_buf = outpicref; |
199 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); |
|
199 |
+ ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); |
|
200 | 200 |
} |
201 | 201 |
|
202 | 202 |
static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } |
... | ... |
@@ -225,8 +227,8 @@ static void end_frame(AVFilterLink *inlink) |
225 | 225 |
av_image_copy_plane(outpic->data[p], outpic->linesize[p], inpic->data[p], inpic->linesize[p], w, h); |
226 | 226 |
} |
227 | 227 |
|
228 |
- avfilter_draw_slice(outlink, 0, inlink->h, 1); |
|
229 |
- avfilter_end_frame(outlink); |
|
228 |
+ ff_draw_slice(outlink, 0, inlink->h, 1); |
|
229 |
+ ff_end_frame(outlink); |
|
230 | 230 |
avfilter_unref_buffer(inpic); |
231 | 231 |
if (outpic != inpic) |
232 | 232 |
avfilter_unref_buffer(outpic); |
... | ... |
@@ -25,6 +25,8 @@ |
25 | 25 |
*/ |
26 | 26 |
|
27 | 27 |
#include "avfilter.h" |
28 |
+#include "formats.h" |
|
29 |
+#include "video.h" |
|
28 | 30 |
#include "libavutil/pixdesc.h" |
29 | 31 |
#include "libavutil/intreadwrite.h" |
30 | 32 |
#include "libavutil/imgutils.h" |
... | ... |
@@ -64,7 +66,7 @@ static int query_formats(AVFilterContext *ctx) |
64 | 64 |
PIX_FMT_NONE |
65 | 65 |
}; |
66 | 66 |
|
67 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
67 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
68 | 68 |
return 0; |
69 | 69 |
} |
70 | 70 |
|
... | ... |
@@ -156,7 +158,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
156 | 156 |
} |
157 | 157 |
} |
158 | 158 |
|
159 |
- avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
|
159 |
+ ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
|
160 | 160 |
} |
161 | 161 |
|
162 | 162 |
AVFilter avfilter_vf_hflip = { |
... | ... |
@@ -27,6 +27,8 @@ |
27 | 27 |
|
28 | 28 |
#include "libavutil/pixdesc.h" |
29 | 29 |
#include "avfilter.h" |
30 |
+#include "formats.h" |
|
31 |
+#include "video.h" |
|
30 | 32 |
|
31 | 33 |
typedef struct { |
32 | 34 |
int Coefs[4][512*16]; |
... | ... |
@@ -268,7 +270,7 @@ static int query_formats(AVFilterContext *ctx) |
268 | 268 |
PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_NONE |
269 | 269 |
}; |
270 | 270 |
|
271 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
271 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
272 | 272 |
|
273 | 273 |
return 0; |
274 | 274 |
} |
... | ... |
@@ -317,8 +319,8 @@ static void end_frame(AVFilterLink *inlink) |
317 | 317 |
hqdn3d->Coefs[2], |
318 | 318 |
hqdn3d->Coefs[3]); |
319 | 319 |
|
320 |
- avfilter_draw_slice(outlink, 0, inpic->video->h, 1); |
|
321 |
- avfilter_end_frame(outlink); |
|
320 |
+ ff_draw_slice(outlink, 0, inpic->video->h, 1); |
|
321 |
+ ff_end_frame(outlink); |
|
322 | 322 |
avfilter_unref_buffer(inpic); |
323 | 323 |
avfilter_unref_buffer(outpic); |
324 | 324 |
} |
... | ... |
@@ -61,7 +61,7 @@ static int query_formats(AVFilterContext *ctx) |
61 | 61 |
PIX_FMT_BGR24, PIX_FMT_BGRA, PIX_FMT_GRAY8, PIX_FMT_NONE |
62 | 62 |
}; |
63 | 63 |
|
64 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
64 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
65 | 65 |
return 0; |
66 | 66 |
} |
67 | 67 |
|
... | ... |
@@ -364,8 +364,8 @@ static void end_frame(AVFilterLink *inlink) |
364 | 364 |
fill_picref_from_iplimage(outpicref, &outimg, inlink->format); |
365 | 365 |
|
366 | 366 |
avfilter_unref_buffer(inpicref); |
367 |
- avfilter_draw_slice(outlink, 0, outlink->h, 1); |
|
368 |
- avfilter_end_frame(outlink); |
|
367 |
+ ff_draw_slice(outlink, 0, outlink->h, 1); |
|
368 |
+ ff_end_frame(outlink); |
|
369 | 369 |
avfilter_unref_buffer(outpicref); |
370 | 370 |
} |
371 | 371 |
|
... | ... |
@@ -28,7 +28,9 @@ |
28 | 28 |
#include "libavutil/opt.h" |
29 | 29 |
#include "libavutil/pixdesc.h" |
30 | 30 |
#include "avfilter.h" |
31 |
+#include "formats.h" |
|
31 | 32 |
#include "internal.h" |
33 |
+#include "video.h" |
|
32 | 34 |
|
33 | 35 |
static const char *const var_names[] = { |
34 | 36 |
"w", ///< width of the input video |
... | ... |
@@ -146,7 +148,7 @@ static int query_formats(AVFilterContext *ctx) |
146 | 146 |
const enum PixelFormat *pix_fmts = lut->is_rgb ? rgb_pix_fmts : |
147 | 147 |
lut->is_yuv ? yuv_pix_fmts : all_pix_fmts; |
148 | 148 |
|
149 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
149 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
150 | 150 |
return 0; |
151 | 151 |
} |
152 | 152 |
|
... | ... |
@@ -334,7 +336,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
334 | 334 |
} |
335 | 335 |
} |
336 | 336 |
|
337 |
- avfilter_draw_slice(outlink, y, h, slice_dir); |
|
337 |
+ ff_draw_slice(outlink, y, h, slice_dir); |
|
338 | 338 |
} |
339 | 339 |
|
340 | 340 |
#define DEFINE_LUT_FILTER(name_, description_, init_) \ |
... | ... |
@@ -28,6 +28,7 @@ |
28 | 28 |
/* #define DEBUG */ |
29 | 29 |
|
30 | 30 |
#include "avfilter.h" |
31 |
+#include "formats.h" |
|
31 | 32 |
#include "libavutil/eval.h" |
32 | 33 |
#include "libavutil/avstring.h" |
33 | 34 |
#include "libavutil/opt.h" |
... | ... |
@@ -38,6 +39,7 @@ |
38 | 38 |
#include "internal.h" |
39 | 39 |
#include "bufferqueue.h" |
40 | 40 |
#include "drawutils.h" |
41 |
+#include "video.h" |
|
41 | 42 |
|
42 | 43 |
static const char *const var_names[] = { |
43 | 44 |
"main_w", "W", ///< width of the main video |
... | ... |
@@ -176,16 +178,16 @@ static int query_formats(AVFilterContext *ctx) |
176 | 176 |
AVFilterFormats *overlay_formats; |
177 | 177 |
|
178 | 178 |
if (over->allow_packed_rgb) { |
179 |
- main_formats = avfilter_make_format_list(main_pix_fmts_rgb); |
|
180 |
- overlay_formats = avfilter_make_format_list(overlay_pix_fmts_rgb); |
|
179 |
+ main_formats = ff_make_format_list(main_pix_fmts_rgb); |
|
180 |
+ overlay_formats = ff_make_format_list(overlay_pix_fmts_rgb); |
|
181 | 181 |
} else { |
182 |
- main_formats = avfilter_make_format_list(main_pix_fmts_yuv); |
|
183 |
- overlay_formats = avfilter_make_format_list(overlay_pix_fmts_yuv); |
|
182 |
+ main_formats = ff_make_format_list(main_pix_fmts_yuv); |
|
183 |
+ overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv); |
|
184 | 184 |
} |
185 | 185 |
|
186 |
- avfilter_formats_ref(main_formats, &ctx->inputs [MAIN ]->out_formats); |
|
187 |
- avfilter_formats_ref(overlay_formats, &ctx->inputs [OVERLAY]->out_formats); |
|
188 |
- avfilter_formats_ref(main_formats, &ctx->outputs[MAIN ]->in_formats ); |
|
186 |
+ ff_formats_ref(main_formats, &ctx->inputs [MAIN ]->out_formats); |
|
187 |
+ ff_formats_ref(overlay_formats, &ctx->inputs [OVERLAY]->out_formats); |
|
188 |
+ ff_formats_ref(main_formats, &ctx->outputs[MAIN ]->in_formats ); |
|
189 | 189 |
|
190 | 190 |
return 0; |
191 | 191 |
} |
... | ... |
@@ -470,7 +472,7 @@ static int try_start_frame(AVFilterContext *ctx, AVFilterBufferRef *mainpic) |
470 | 470 |
av_ts2str(over->overpicref->pts), av_ts2timestr(over->overpicref->pts, &outlink->time_base)); |
471 | 471 |
av_dlog(ctx, "\n"); |
472 | 472 |
|
473 |
- avfilter_start_frame(ctx->outputs[0], avfilter_ref_buffer(outpicref, ~0)); |
|
473 |
+ ff_start_frame(ctx->outputs[0], avfilter_ref_buffer(outpicref, ~0)); |
|
474 | 474 |
over->frame_requested = 0; |
475 | 475 |
return 0; |
476 | 476 |
} |
... | ... |
@@ -498,9 +500,9 @@ static int try_push_frame(AVFilterContext *ctx) |
498 | 498 |
blend_slice(ctx, outpicref, over->overpicref, over->x, over->y, |
499 | 499 |
over->overpicref->video->w, over->overpicref->video->h, |
500 | 500 |
0, outpicref->video->w, outpicref->video->h); |
501 |
- avfilter_draw_slice(outlink, 0, outpicref->video->h, +1); |
|
501 |
+ ff_draw_slice(outlink, 0, outpicref->video->h, +1); |
|
502 | 502 |
avfilter_unref_bufferp(&outlink->out_buf); |
503 |
- avfilter_end_frame(outlink); |
|
503 |
+ ff_end_frame(outlink); |
|
504 | 504 |
return 0; |
505 | 505 |
} |
506 | 506 |
|
... | ... |
@@ -536,7 +538,7 @@ static void draw_slice_main(AVFilterLink *inlink, int y, int h, int slice_dir) |
536 | 536 |
over->overpicref->video->w, over->overpicref->video->h, |
537 | 537 |
y, outpicref->video->w, h); |
538 | 538 |
} |
539 |
- avfilter_draw_slice(outlink, y, h, slice_dir); |
|
539 |
+ ff_draw_slice(outlink, y, h, slice_dir); |
|
540 | 540 |
} |
541 | 541 |
|
542 | 542 |
static void end_frame_main(AVFilterLink *inlink) |
... | ... |
@@ -550,7 +552,7 @@ static void end_frame_main(AVFilterLink *inlink) |
550 | 550 |
return; |
551 | 551 |
avfilter_unref_bufferp(&inlink->cur_buf); |
552 | 552 |
avfilter_unref_bufferp(&outlink->out_buf); |
553 |
- avfilter_end_frame(ctx->outputs[0]); |
|
553 |
+ ff_end_frame(ctx->outputs[0]); |
|
554 | 554 |
} |
555 | 555 |
|
556 | 556 |
static void start_frame_over(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
... | ... |
@@ -584,7 +586,7 @@ static int request_frame(AVFilterLink *outlink) |
584 | 584 |
input = !over->overlay_eof && (over->queue_main.available || |
585 | 585 |
over->queue_over.available < 2) ? |
586 | 586 |
OVERLAY : MAIN; |
587 |
- ret = avfilter_request_frame(ctx->inputs[input]); |
|
587 |
+ ret = ff_request_frame(ctx->inputs[input]); |
|
588 | 588 |
/* EOF on main is reported immediately */ |
589 | 589 |
if (ret == AVERROR_EOF && input == OVERLAY) { |
590 | 590 |
over->overlay_eof = 1; |
... | ... |
@@ -25,6 +25,8 @@ |
25 | 25 |
*/ |
26 | 26 |
|
27 | 27 |
#include "avfilter.h" |
28 |
+#include "formats.h" |
|
29 |
+#include "video.h" |
|
28 | 30 |
#include "libavutil/avstring.h" |
29 | 31 |
#include "libavutil/eval.h" |
30 | 32 |
#include "libavutil/pixdesc.h" |
... | ... |
@@ -67,7 +69,7 @@ enum var_name { |
67 | 67 |
|
68 | 68 |
static int query_formats(AVFilterContext *ctx) |
69 | 69 |
{ |
70 |
- avfilter_set_common_pixel_formats(ctx, ff_draw_supported_pixel_formats(0)); |
|
70 |
+ ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0)); |
|
71 | 71 |
return 0; |
72 | 72 |
} |
73 | 73 |
|
... | ... |
@@ -296,7 +298,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
296 | 296 |
outpicref->video->w = pad->w; |
297 | 297 |
outpicref->video->h = pad->h; |
298 | 298 |
|
299 |
- avfilter_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(outpicref, ~0)); |
|
299 |
+ ff_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(outpicref, ~0)); |
|
300 | 300 |
} |
301 | 301 |
|
302 | 302 |
static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice) |
... | ... |
@@ -319,7 +321,7 @@ static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, |
319 | 319 |
link->dst->outputs[0]->out_buf->data, |
320 | 320 |
link->dst->outputs[0]->out_buf->linesize, |
321 | 321 |
0, bar_y, pad->w, bar_h); |
322 |
- avfilter_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir); |
|
322 |
+ ff_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir); |
|
323 | 323 |
} |
324 | 324 |
} |
325 | 325 |
|
... | ... |
@@ -352,7 +354,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
352 | 352 |
/* right border */ |
353 | 353 |
ff_fill_rectangle(&pad->draw, &pad->color, outpic->data, outpic->linesize, |
354 | 354 |
pad->x + pad->in_w, y, pad->w - pad->x - pad->in_w, h); |
355 |
- avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); |
|
355 |
+ ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); |
|
356 | 356 |
|
357 | 357 |
draw_send_bar_slice(link, y, h, slice_dir, -1); |
358 | 358 |
} |
... | ... |
@@ -25,6 +25,7 @@ |
25 | 25 |
|
26 | 26 |
#include "libavutil/pixdesc.h" |
27 | 27 |
#include "avfilter.h" |
28 |
+#include "video.h" |
|
28 | 29 |
|
29 | 30 |
typedef struct { |
30 | 31 |
const AVPixFmtDescriptor *pix_desc; |
... | ... |
@@ -76,7 +77,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
76 | 76 |
priv->pix_desc->flags & PIX_FMT_PSEUDOPAL) |
77 | 77 |
memcpy(outpicref->data[1], picref->data[1], AVPALETTE_SIZE); |
78 | 78 |
|
79 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); |
|
79 |
+ ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); |
|
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
... | ... |
@@ -106,7 +107,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
106 | 106 |
} |
107 | 107 |
} |
108 | 108 |
|
109 |
- avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
|
109 |
+ ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
|
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
AVFilter avfilter_vf_pixdesctest = { |
... | ... |
@@ -24,6 +24,8 @@ |
24 | 24 |
*/ |
25 | 25 |
|
26 | 26 |
#include "avfilter.h" |
27 |
+#include "formats.h" |
|
28 |
+#include "video.h" |
|
27 | 29 |
#include "libavutil/avstring.h" |
28 | 30 |
#include "libavutil/eval.h" |
29 | 31 |
#include "libavutil/mathematics.h" |
... | ... |
@@ -130,21 +132,21 @@ static int query_formats(AVFilterContext *ctx) |
130 | 130 |
formats = NULL; |
131 | 131 |
for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) |
132 | 132 |
if ( sws_isSupportedInput(pix_fmt) |
133 |
- && (ret = avfilter_add_format(&formats, pix_fmt)) < 0) { |
|
134 |
- avfilter_formats_unref(&formats); |
|
133 |
+ && (ret = ff_add_format(&formats, pix_fmt)) < 0) { |
|
134 |
+ ff_formats_unref(&formats); |
|
135 | 135 |
return ret; |
136 | 136 |
} |
137 |
- avfilter_formats_ref(formats, &ctx->inputs[0]->out_formats); |
|
137 |
+ ff_formats_ref(formats, &ctx->inputs[0]->out_formats); |
|
138 | 138 |
} |
139 | 139 |
if (ctx->outputs[0]) { |
140 | 140 |
formats = NULL; |
141 | 141 |
for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) |
142 | 142 |
if ( (sws_isSupportedOutput(pix_fmt) || pix_fmt == PIX_FMT_PAL8) |
143 |
- && (ret = avfilter_add_format(&formats, pix_fmt)) < 0) { |
|
144 |
- avfilter_formats_unref(&formats); |
|
143 |
+ && (ret = ff_add_format(&formats, pix_fmt)) < 0) { |
|
144 |
+ ff_formats_unref(&formats); |
|
145 | 145 |
return ret; |
146 | 146 |
} |
147 |
- avfilter_formats_ref(formats, &ctx->outputs[0]->in_formats); |
|
147 |
+ ff_formats_ref(formats, &ctx->outputs[0]->in_formats); |
|
148 | 148 |
} |
149 | 149 |
|
150 | 150 |
return 0; |
... | ... |
@@ -293,7 +295,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
293 | 293 |
|
294 | 294 |
|
295 | 295 |
if (!scale->sws) { |
296 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); |
|
296 |
+ ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); |
|
297 | 297 |
return; |
298 | 298 |
} |
299 | 299 |
|
... | ... |
@@ -315,7 +317,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
315 | 315 |
INT_MAX); |
316 | 316 |
|
317 | 317 |
scale->slice_y = 0; |
318 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); |
|
318 |
+ ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); |
|
319 | 319 |
} |
320 | 320 |
|
321 | 321 |
static int scale_slice(AVFilterLink *link, struct SwsContext *sws, int y, int h, int mul, int field) |
... | ... |
@@ -350,7 +352,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
350 | 350 |
int out_h; |
351 | 351 |
|
352 | 352 |
if (!scale->sws) { |
353 |
- avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); |
|
353 |
+ ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); |
|
354 | 354 |
return; |
355 | 355 |
} |
356 | 356 |
|
... | ... |
@@ -367,7 +369,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
367 | 367 |
|
368 | 368 |
if (slice_dir == -1) |
369 | 369 |
scale->slice_y -= out_h; |
370 |
- avfilter_draw_slice(link->dst->outputs[0], scale->slice_y, out_h, slice_dir); |
|
370 |
+ ff_draw_slice(link->dst->outputs[0], scale->slice_y, out_h, slice_dir); |
|
371 | 371 |
if (slice_dir == 1) |
372 | 372 |
scale->slice_y += out_h; |
373 | 373 |
} |
... | ... |
@@ -28,6 +28,7 @@ |
28 | 28 |
#include "libavcodec/dsputil.h" |
29 | 29 |
#include "avfilter.h" |
30 | 30 |
#include "formats.h" |
31 |
+#include "internal.h" |
|
31 | 32 |
#include "video.h" |
32 | 33 |
|
33 | 34 |
static const char *const var_names[] = { |
... | ... |
@@ -284,7 +285,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
284 | 284 |
sizeof(picref), NULL); |
285 | 285 |
return; |
286 | 286 |
} |
287 |
- avfilter_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); |
|
287 |
+ ff_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); |
|
288 | 288 |
} |
289 | 289 |
} |
290 | 290 |
|
... | ... |
@@ -293,7 +294,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
293 | 293 |
SelectContext *select = inlink->dst->priv; |
294 | 294 |
|
295 | 295 |
if (select->select && !select->cache_frames) |
296 |
- avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
|
296 |
+ ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
|
297 | 297 |
} |
298 | 298 |
|
299 | 299 |
static void end_frame(AVFilterLink *inlink) |
... | ... |
@@ -304,7 +305,7 @@ static void end_frame(AVFilterLink *inlink) |
304 | 304 |
if (select->select) { |
305 | 305 |
if (select->cache_frames) |
306 | 306 |
return; |
307 |
- avfilter_end_frame(inlink->dst->outputs[0]); |
|
307 |
+ ff_end_frame(inlink->dst->outputs[0]); |
|
308 | 308 |
} |
309 | 309 |
avfilter_unref_buffer(picref); |
310 | 310 |
} |
... | ... |
@@ -319,15 +320,15 @@ static int request_frame(AVFilterLink *outlink) |
319 | 319 |
if (av_fifo_size(select->pending_frames)) { |
320 | 320 |
AVFilterBufferRef *picref; |
321 | 321 |
av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL); |
322 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); |
|
323 |
- avfilter_draw_slice(outlink, 0, outlink->h, 1); |
|
324 |
- avfilter_end_frame(outlink); |
|
322 |
+ ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); |
|
323 |
+ ff_draw_slice(outlink, 0, outlink->h, 1); |
|
324 |
+ ff_end_frame(outlink); |
|
325 | 325 |
avfilter_unref_buffer(picref); |
326 | 326 |
return 0; |
327 | 327 |
} |
328 | 328 |
|
329 | 329 |
while (!select->select) { |
330 |
- int ret = avfilter_request_frame(inlink); |
|
330 |
+ int ret = ff_request_frame(inlink); |
|
331 | 331 |
if (ret < 0) |
332 | 332 |
return ret; |
333 | 333 |
} |
... | ... |
@@ -342,12 +343,12 @@ static int poll_frame(AVFilterLink *outlink) |
342 | 342 |
int count, ret; |
343 | 343 |
|
344 | 344 |
if (!av_fifo_size(select->pending_frames)) { |
345 |
- if ((count = avfilter_poll_frame(inlink)) <= 0) |
|
345 |
+ if ((count = ff_poll_frame(inlink)) <= 0) |
|
346 | 346 |
return count; |
347 | 347 |
/* request frame from input, and apply select condition to it */ |
348 | 348 |
select->cache_frames = 1; |
349 | 349 |
while (count-- && av_fifo_space(select->pending_frames)) { |
350 |
- ret = avfilter_request_frame(inlink); |
|
350 |
+ ret = ff_request_frame(inlink); |
|
351 | 351 |
if (ret < 0) |
352 | 352 |
break; |
353 | 353 |
} |
... | ... |
@@ -120,7 +120,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
120 | 120 |
setpts->var_values[VAR_N] += 1.0; |
121 | 121 |
setpts->var_values[VAR_PREV_INPTS ] = TS2D(inpicref ->pts); |
122 | 122 |
setpts->var_values[VAR_PREV_OUTPTS] = TS2D(outpicref->pts); |
123 |
- avfilter_start_frame(inlink->dst->outputs[0], outpicref); |
|
123 |
+ ff_start_frame(inlink->dst->outputs[0], outpicref); |
|
124 | 124 |
} |
125 | 125 |
|
126 | 126 |
static av_cold void uninit(AVFilterContext *ctx) |
... | ... |
@@ -110,7 +110,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
110 | 110 |
avfilter_unref_buffer(picref); |
111 | 111 |
} |
112 | 112 |
|
113 |
- avfilter_start_frame(outlink, picref2); |
|
113 |
+ ff_start_frame(outlink, picref2); |
|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
AVFilter avfilter_vf_settb = { |
... | ... |
@@ -73,7 +73,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
73 | 73 |
|
74 | 74 |
av_log(link->dst, AV_LOG_DEBUG, "h:%d\n", slice->h); |
75 | 75 |
|
76 |
- avfilter_start_frame(link->dst->outputs[0], picref); |
|
76 |
+ ff_start_frame(link->dst->outputs[0], picref); |
|
77 | 77 |
} |
78 | 78 |
|
79 | 79 |
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
... | ... |
@@ -83,16 +83,16 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
83 | 83 |
|
84 | 84 |
if (slice_dir == 1) { |
85 | 85 |
for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h) |
86 |
- avfilter_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir); |
|
86 |
+ ff_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir); |
|
87 | 87 |
|
88 | 88 |
if (y2 < y + h) |
89 |
- avfilter_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir); |
|
89 |
+ ff_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir); |
|
90 | 90 |
} else if (slice_dir == -1) { |
91 | 91 |
for (y2 = y + h; y2 - slice->h >= y; y2 -= slice->h) |
92 |
- avfilter_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir); |
|
92 |
+ ff_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir); |
|
93 | 93 |
|
94 | 94 |
if (y2 > y) |
95 |
- avfilter_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir); |
|
95 |
+ ff_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir); |
|
96 | 96 |
} |
97 | 97 |
} |
98 | 98 |
|
... | ... |
@@ -29,6 +29,8 @@ |
29 | 29 |
#include "libavutil/pixdesc.h" |
30 | 30 |
#include "libavutil/imgutils.h" |
31 | 31 |
#include "avfilter.h" |
32 |
+#include "formats.h" |
|
33 |
+#include "video.h" |
|
32 | 34 |
|
33 | 35 |
typedef struct { |
34 | 36 |
int hsub, vsub; |
... | ... |
@@ -80,7 +82,7 @@ static int query_formats(AVFilterContext *ctx) |
80 | 80 |
PIX_FMT_NONE |
81 | 81 |
}; |
82 | 82 |
|
83 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
83 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
84 | 84 |
return 0; |
85 | 85 |
} |
86 | 86 |
|
... | ... |
@@ -126,7 +128,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
126 | 126 |
outlink->out_buf->video->sample_aspect_ratio.den = picref->video->sample_aspect_ratio.num; |
127 | 127 |
} |
128 | 128 |
|
129 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); |
|
129 |
+ ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); |
|
130 | 130 |
} |
131 | 131 |
|
132 | 132 |
static void end_frame(AVFilterLink *inlink) |
... | ... |
@@ -187,8 +189,8 @@ static void end_frame(AVFilterLink *inlink) |
187 | 187 |
} |
188 | 188 |
|
189 | 189 |
avfilter_unref_buffer(inpic); |
190 |
- avfilter_draw_slice(outlink, 0, outpic->video->h, 1); |
|
191 |
- avfilter_end_frame(outlink); |
|
190 |
+ ff_draw_slice(outlink, 0, outpic->video->h, 1); |
|
191 |
+ ff_end_frame(outlink); |
|
192 | 192 |
avfilter_unref_buffer(outpic); |
193 | 193 |
} |
194 | 194 |
|
... | ... |
@@ -37,6 +37,8 @@ |
37 | 37 |
*/ |
38 | 38 |
|
39 | 39 |
#include "avfilter.h" |
40 |
+#include "formats.h" |
|
41 |
+#include "video.h" |
|
40 | 42 |
#include "libavutil/common.h" |
41 | 43 |
#include "libavutil/mem.h" |
42 | 44 |
#include "libavutil/pixdesc.h" |
... | ... |
@@ -162,7 +164,7 @@ static int query_formats(AVFilterContext *ctx) |
162 | 162 |
PIX_FMT_YUVJ444P, PIX_FMT_YUVJ440P, PIX_FMT_NONE |
163 | 163 |
}; |
164 | 164 |
|
165 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
165 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
166 | 166 |
|
167 | 167 |
return 0; |
168 | 168 |
} |
... | ... |
@@ -223,8 +225,8 @@ static void end_frame(AVFilterLink *link) |
223 | 223 |
apply_unsharp(out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, &unsharp->chroma); |
224 | 224 |
|
225 | 225 |
avfilter_unref_buffer(in); |
226 |
- avfilter_draw_slice(link->dst->outputs[0], 0, link->h, 1); |
|
227 |
- avfilter_end_frame(link->dst->outputs[0]); |
|
226 |
+ ff_draw_slice(link->dst->outputs[0], 0, link->h, 1); |
|
227 |
+ ff_end_frame(link->dst->outputs[0]); |
|
228 | 228 |
avfilter_unref_buffer(out); |
229 | 229 |
} |
230 | 230 |
|
... | ... |
@@ -78,14 +78,14 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref) |
78 | 78 |
} |
79 | 79 |
} |
80 | 80 |
|
81 |
- avfilter_start_frame(link->dst->outputs[0], outpicref); |
|
81 |
+ ff_start_frame(link->dst->outputs[0], outpicref); |
|
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
85 | 85 |
{ |
86 | 86 |
AVFilterContext *ctx = link->dst; |
87 | 87 |
|
88 |
- avfilter_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir); |
|
88 |
+ ff_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir); |
|
89 | 89 |
} |
90 | 90 |
|
91 | 91 |
AVFilter avfilter_vf_vflip = { |
... | ... |
@@ -22,6 +22,8 @@ |
22 | 22 |
#include "libavutil/common.h" |
23 | 23 |
#include "libavutil/pixdesc.h" |
24 | 24 |
#include "avfilter.h" |
25 |
+#include "formats.h" |
|
26 |
+#include "internal.h" |
|
25 | 27 |
#include "video.h" |
26 | 28 |
#include "yadif.h" |
27 | 29 |
|
... | ... |
@@ -227,10 +229,10 @@ static void return_frame(AVFilterContext *ctx, int is_second) |
227 | 227 |
} else { |
228 | 228 |
yadif->out->pts = AV_NOPTS_VALUE; |
229 | 229 |
} |
230 |
- avfilter_start_frame(ctx->outputs[0], yadif->out); |
|
230 |
+ ff_start_frame(ctx->outputs[0], yadif->out); |
|
231 | 231 |
} |
232 |
- avfilter_draw_slice(ctx->outputs[0], 0, link->h, 1); |
|
233 |
- avfilter_end_frame(ctx->outputs[0]); |
|
232 |
+ ff_draw_slice(ctx->outputs[0], 0, link->h, 1); |
|
233 |
+ ff_end_frame(ctx->outputs[0]); |
|
234 | 234 |
|
235 | 235 |
yadif->frame_pending = (yadif->mode&1) && !is_second; |
236 | 236 |
} |
... | ... |
@@ -260,7 +262,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
260 | 260 |
yadif->prev = NULL; |
261 | 261 |
if (yadif->out->pts != AV_NOPTS_VALUE) |
262 | 262 |
yadif->out->pts *= 2; |
263 |
- avfilter_start_frame(ctx->outputs[0], yadif->out); |
|
263 |
+ ff_start_frame(ctx->outputs[0], yadif->out); |
|
264 | 264 |
return; |
265 | 265 |
} |
266 | 266 |
|
... | ... |
@@ -274,7 +276,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
274 | 274 |
yadif->out->video->interlaced = 0; |
275 | 275 |
if (yadif->out->pts != AV_NOPTS_VALUE) |
276 | 276 |
yadif->out->pts *= 2; |
277 |
- avfilter_start_frame(ctx->outputs[0], yadif->out); |
|
277 |
+ ff_start_frame(ctx->outputs[0], yadif->out); |
|
278 | 278 |
} |
279 | 279 |
|
280 | 280 |
static void end_frame(AVFilterLink *link) |
... | ... |
@@ -286,8 +288,8 @@ static void end_frame(AVFilterLink *link) |
286 | 286 |
return; |
287 | 287 |
|
288 | 288 |
if (yadif->auto_enable && !yadif->cur->video->interlaced) { |
289 |
- avfilter_draw_slice(ctx->outputs[0], 0, link->h, 1); |
|
290 |
- avfilter_end_frame(ctx->outputs[0]); |
|
289 |
+ ff_draw_slice(ctx->outputs[0], 0, link->h, 1); |
|
290 |
+ ff_end_frame(ctx->outputs[0]); |
|
291 | 291 |
return; |
292 | 292 |
} |
293 | 293 |
|
... | ... |
@@ -310,7 +312,7 @@ static int request_frame(AVFilterLink *link) |
310 | 310 |
if (yadif->eof) |
311 | 311 |
return AVERROR_EOF; |
312 | 312 |
|
313 |
- ret = avfilter_request_frame(link->src->inputs[0]); |
|
313 |
+ ret = ff_request_frame(link->src->inputs[0]); |
|
314 | 314 |
|
315 | 315 |
if (ret == AVERROR_EOF && yadif->cur) { |
316 | 316 |
AVFilterBufferRef *next = avfilter_ref_buffer(yadif->next, AV_PERM_READ); |
... | ... |
@@ -335,14 +337,14 @@ static int poll_frame(AVFilterLink *link) |
335 | 335 |
if (yadif->frame_pending) |
336 | 336 |
return 1; |
337 | 337 |
|
338 |
- val = avfilter_poll_frame(link->src->inputs[0]); |
|
338 |
+ val = ff_poll_frame(link->src->inputs[0]); |
|
339 | 339 |
if (val <= 0) |
340 | 340 |
return val; |
341 | 341 |
|
342 | 342 |
if (val >= 1 && !yadif->next) { //FIXME change API to not requre this red tape |
343 |
- if ((ret = avfilter_request_frame(link->src->inputs[0])) < 0) |
|
343 |
+ if ((ret = ff_request_frame(link->src->inputs[0])) < 0) |
|
344 | 344 |
return ret; |
345 |
- val = avfilter_poll_frame(link->src->inputs[0]); |
|
345 |
+ val = ff_poll_frame(link->src->inputs[0]); |
|
346 | 346 |
if (val <= 0) |
347 | 347 |
return val; |
348 | 348 |
} |
... | ... |
@@ -390,7 +392,7 @@ static int query_formats(AVFilterContext *ctx) |
390 | 390 |
PIX_FMT_NONE |
391 | 391 |
}; |
392 | 392 |
|
393 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
393 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
394 | 394 |
|
395 | 395 |
return 0; |
396 | 396 |
} |
... | ... |
@@ -151,7 +151,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int |
151 | 151 |
|
152 | 152 |
void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
153 | 153 |
{ |
154 |
- avfilter_start_frame(link->dst->outputs[0], picref); |
|
154 |
+ ff_start_frame(link->dst->outputs[0], picref); |
|
155 | 155 |
} |
156 | 156 |
|
157 | 157 |
static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
... | ... |
@@ -164,13 +164,13 @@ static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
164 | 164 |
if (outlink) { |
165 | 165 |
outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); |
166 | 166 |
avfilter_copy_buffer_ref_props(outlink->out_buf, picref); |
167 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); |
|
167 |
+ ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); |
|
168 | 168 |
} |
169 | 169 |
} |
170 | 170 |
|
171 | 171 |
/* XXX: should we do the duplicating of the picture ref here, instead of |
172 | 172 |
* forcing the source filter to do it? */ |
173 |
-void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
|
173 |
+void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
|
174 | 174 |
{ |
175 | 175 |
void (*start_frame)(AVFilterLink *, AVFilterBufferRef *); |
176 | 176 |
AVFilterPad *dst = link->dstpad; |
... | ... |
@@ -217,7 +217,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
217 | 217 |
|
218 | 218 |
void ff_null_end_frame(AVFilterLink *link) |
219 | 219 |
{ |
220 |
- avfilter_end_frame(link->dst->outputs[0]); |
|
220 |
+ ff_end_frame(link->dst->outputs[0]); |
|
221 | 221 |
} |
222 | 222 |
|
223 | 223 |
static void default_end_frame(AVFilterLink *inlink) |
... | ... |
@@ -235,11 +235,11 @@ static void default_end_frame(AVFilterLink *inlink) |
235 | 235 |
avfilter_unref_buffer(outlink->out_buf); |
236 | 236 |
outlink->out_buf = NULL; |
237 | 237 |
} |
238 |
- avfilter_end_frame(outlink); |
|
238 |
+ ff_end_frame(outlink); |
|
239 | 239 |
} |
240 | 240 |
} |
241 | 241 |
|
242 |
-void avfilter_end_frame(AVFilterLink *link) |
|
242 |
+void ff_end_frame(AVFilterLink *link) |
|
243 | 243 |
{ |
244 | 244 |
void (*end_frame)(AVFilterLink *); |
245 | 245 |
|
... | ... |
@@ -258,7 +258,7 @@ void avfilter_end_frame(AVFilterLink *link) |
258 | 258 |
|
259 | 259 |
void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
260 | 260 |
{ |
261 |
- avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); |
|
261 |
+ ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); |
|
262 | 262 |
} |
263 | 263 |
|
264 | 264 |
static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
... | ... |
@@ -269,10 +269,10 @@ static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir |
269 | 269 |
outlink = inlink->dst->outputs[0]; |
270 | 270 |
|
271 | 271 |
if (outlink) |
272 |
- avfilter_draw_slice(outlink, y, h, slice_dir); |
|
272 |
+ ff_draw_slice(outlink, y, h, slice_dir); |
|
273 | 273 |
} |
274 | 274 |
|
275 |
-void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
|
275 |
+void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
|
276 | 276 |
{ |
277 | 277 |
uint8_t *src[4], *dst[4]; |
278 | 278 |
int i, j, vsub; |
... | ... |
@@ -346,4 +346,16 @@ void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
346 | 346 |
{ |
347 | 347 |
ff_null_draw_slice(link, y, h, slice_dir); |
348 | 348 |
} |
349 |
+void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
|
350 |
+{ |
|
351 |
+ ff_start_frame(link, picref); |
|
352 |
+} |
|
353 |
+void avfilter_end_frame(AVFilterLink *link) |
|
354 |
+{ |
|
355 |
+ ff_end_frame(link); |
|
356 |
+} |
|
357 |
+void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
|
358 |
+{ |
|
359 |
+ ff_draw_slice(link, y, h, slice_dir); |
|
360 |
+} |
|
349 | 361 |
#endif |
... | ... |
@@ -33,4 +33,39 @@ void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); |
33 | 33 |
void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); |
34 | 34 |
void ff_null_end_frame(AVFilterLink *link); |
35 | 35 |
|
36 |
+/** |
|
37 |
+ * Notify the next filter of the start of a frame. |
|
38 |
+ * |
|
39 |
+ * @param link the output link the frame will be sent over |
|
40 |
+ * @param picref A reference to the frame about to be sent. The data for this |
|
41 |
+ * frame need only be valid once draw_slice() is called for that |
|
42 |
+ * portion. The receiving filter will free this reference when |
|
43 |
+ * it no longer needs it. |
|
44 |
+ */ |
|
45 |
+void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); |
|
46 |
+ |
|
47 |
+/** |
|
48 |
+ * Notify the next filter that the current frame has finished. |
|
49 |
+ * |
|
50 |
+ * @param link the output link the frame was sent over |
|
51 |
+ */ |
|
52 |
+void ff_end_frame(AVFilterLink *link); |
|
53 |
+ |
|
54 |
+/** |
|
55 |
+ * Send a slice to the next filter. |
|
56 |
+ * |
|
57 |
+ * Slices have to be provided in sequential order, either in |
|
58 |
+ * top-bottom or bottom-top order. If slices are provided in |
|
59 |
+ * non-sequential order the behavior of the function is undefined. |
|
60 |
+ * |
|
61 |
+ * @param link the output link over which the frame is being sent |
|
62 |
+ * @param y offset in pixels from the top of the image for this slice |
|
63 |
+ * @param h height of this slice in pixels |
|
64 |
+ * @param slice_dir the assumed direction for sending slices, |
|
65 |
+ * from the top slice to the bottom slice if the value is 1, |
|
66 |
+ * from the bottom slice to the top slice if the value is -1, |
|
67 |
+ * for other values the behavior of the function is undefined. |
|
68 |
+ */ |
|
69 |
+void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); |
|
70 |
+ |
|
36 | 71 |
#endif /* AVFILTER_VIDEO_H */ |
... | ... |
@@ -24,6 +24,8 @@ |
24 | 24 |
*/ |
25 | 25 |
|
26 | 26 |
#include "avfilter.h" |
27 |
+#include "formats.h" |
|
28 |
+#include "video.h" |
|
27 | 29 |
#include "libavutil/pixdesc.h" |
28 | 30 |
#include "libavutil/colorspace.h" |
29 | 31 |
#include "libavutil/imgutils.h" |
... | ... |
@@ -73,7 +75,7 @@ static av_cold int color_init(AVFilterContext *ctx, const char *args, void *opaq |
73 | 73 |
|
74 | 74 |
static int query_formats(AVFilterContext *ctx) |
75 | 75 |
{ |
76 |
- avfilter_set_common_pixel_formats(ctx, ff_draw_supported_pixel_formats(0)); |
|
76 |
+ ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0)); |
|
77 | 77 |
return 0; |
78 | 78 |
} |
79 | 79 |
|
... | ... |
@@ -108,11 +110,11 @@ static int color_request_frame(AVFilterLink *link) |
108 | 108 |
picref->pts = color->pts++; |
109 | 109 |
picref->pos = -1; |
110 | 110 |
|
111 |
- avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0)); |
|
111 |
+ ff_start_frame(link, avfilter_ref_buffer(picref, ~0)); |
|
112 | 112 |
ff_fill_rectangle(&color->draw, &color->color, picref->data, picref->linesize, |
113 | 113 |
0, 0, color->w, color->h); |
114 |
- avfilter_draw_slice(link, 0, color->h, 1); |
|
115 |
- avfilter_end_frame(link); |
|
114 |
+ ff_draw_slice(link, 0, color->h, 1); |
|
115 |
+ ff_end_frame(link); |
|
116 | 116 |
avfilter_unref_buffer(picref); |
117 | 117 |
|
118 | 118 |
return 0; |
... | ... |
@@ -36,6 +36,8 @@ |
36 | 36 |
#include "libavutil/intreadwrite.h" |
37 | 37 |
#include "libavutil/parseutils.h" |
38 | 38 |
#include "avfilter.h" |
39 |
+#include "formats.h" |
|
40 |
+#include "video.h" |
|
39 | 41 |
|
40 | 42 |
typedef struct { |
41 | 43 |
const AVClass *class; |
... | ... |
@@ -146,9 +148,9 @@ static int request_frame(AVFilterLink *outlink) |
146 | 146 |
test->fill_picture_fn(outlink->src, picref); |
147 | 147 |
test->nb_frame++; |
148 | 148 |
|
149 |
- avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); |
|
150 |
- avfilter_draw_slice(outlink, 0, picref->video->h, 1); |
|
151 |
- avfilter_end_frame(outlink); |
|
149 |
+ ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); |
|
150 |
+ ff_draw_slice(outlink, 0, picref->video->h, 1); |
|
151 |
+ ff_end_frame(outlink); |
|
152 | 152 |
avfilter_unref_buffer(picref); |
153 | 153 |
|
154 | 154 |
return 0; |
... | ... |
@@ -388,7 +390,7 @@ static int test_query_formats(AVFilterContext *ctx) |
388 | 388 |
static const enum PixelFormat pix_fmts[] = { |
389 | 389 |
PIX_FMT_RGB24, PIX_FMT_NONE |
390 | 390 |
}; |
391 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
391 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
392 | 392 |
return 0; |
393 | 393 |
} |
394 | 394 |
|
... | ... |
@@ -494,7 +496,7 @@ static int rgbtest_query_formats(AVFilterContext *ctx) |
494 | 494 |
PIX_FMT_RGB555, PIX_FMT_BGR555, |
495 | 495 |
PIX_FMT_NONE |
496 | 496 |
}; |
497 |
- avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
497 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
498 | 498 |
return 0; |
499 | 499 |
} |
500 | 500 |
|
... | ... |
@@ -345,6 +345,7 @@ const AVCodecTag ff_codec_wav_tags[] = { |
345 | 345 |
{ CODEC_ID_ATRAC3, 0x0270 }, |
346 | 346 |
{ CODEC_ID_ADPCM_G722, 0x028F }, |
347 | 347 |
{ CODEC_ID_IMC, 0x0401 }, |
348 |
+ { CODEC_ID_IAC, 0x0402 }, |
|
348 | 349 |
{ CODEC_ID_GSM_MS, 0x1500 }, |
349 | 350 |
{ CODEC_ID_TRUESPEECH, 0x1501 }, |
350 | 351 |
{ CODEC_ID_AAC, 0x1600 }, /* ADTS AAC */ |
... | ... |
@@ -673,6 +673,42 @@ fail: |
673 | 673 |
|
674 | 674 |
/*******************************************************/ |
675 | 675 |
|
676 |
+static void probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt) |
|
677 |
+{ |
|
678 |
+ if(st->request_probe>0){ |
|
679 |
+ AVProbeData *pd = &st->probe_data; |
|
680 |
+ int end; |
|
681 |
+ av_log(s, AV_LOG_DEBUG, "probing stream %d pp:%d\n", st->index, st->probe_packets); |
|
682 |
+ --st->probe_packets; |
|
683 |
+ |
|
684 |
+ if (pkt) { |
|
685 |
+ pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE); |
|
686 |
+ memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size); |
|
687 |
+ pd->buf_size += pkt->size; |
|
688 |
+ memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE); |
|
689 |
+ } else { |
|
690 |
+ st->probe_packets = 0; |
|
691 |
+ } |
|
692 |
+ |
|
693 |
+ end= s->raw_packet_buffer_remaining_size <= 0 |
|
694 |
+ || st->probe_packets<=0; |
|
695 |
+ |
|
696 |
+ if(end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){ |
|
697 |
+ int score= set_codec_from_probe_data(s, st, pd); |
|
698 |
+ if( (st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4) |
|
699 |
+ || end){ |
|
700 |
+ pd->buf_size=0; |
|
701 |
+ av_freep(&pd->buf); |
|
702 |
+ st->request_probe= -1; |
|
703 |
+ if(st->codec->codec_id != CODEC_ID_NONE){ |
|
704 |
+ av_log(s, AV_LOG_DEBUG, "probed stream %d\n", st->index); |
|
705 |
+ }else |
|
706 |
+ av_log(s, AV_LOG_WARNING, "probed stream %d failed\n", st->index); |
|
707 |
+ } |
|
708 |
+ } |
|
709 |
+ } |
|
710 |
+} |
|
711 |
+ |
|
676 | 712 |
int ff_read_packet(AVFormatContext *s, AVPacket *pkt) |
677 | 713 |
{ |
678 | 714 |
int ret, i; |
... | ... |
@@ -683,7 +719,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) |
683 | 683 |
|
684 | 684 |
if (pktl) { |
685 | 685 |
*pkt = pktl->pkt; |
686 |
- if(s->streams[pkt->stream_index]->request_probe <= 0){ |
|
686 |
+ st = s->streams[pkt->stream_index]; |
|
687 |
+ if(st->request_probe <= 0){ |
|
687 | 688 |
s->raw_packet_buffer = pktl->next; |
688 | 689 |
s->raw_packet_buffer_remaining_size += pkt->size; |
689 | 690 |
av_free(pktl); |
... | ... |
@@ -696,9 +733,13 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) |
696 | 696 |
if (ret < 0) { |
697 | 697 |
if (!pktl || ret == AVERROR(EAGAIN)) |
698 | 698 |
return ret; |
699 |
- for (i = 0; i < s->nb_streams; i++) |
|
700 |
- if(s->streams[i]->request_probe > 0) |
|
701 |
- s->streams[i]->request_probe = -1; |
|
699 |
+ for (i = 0; i < s->nb_streams; i++) { |
|
700 |
+ st = s->streams[i]; |
|
701 |
+ if (st->probe_packets) { |
|
702 |
+ probe_codec(s, st, NULL); |
|
703 |
+ } |
|
704 |
+ av_assert0(st->request_probe <= 0); |
|
705 |
+ } |
|
702 | 706 |
continue; |
703 | 707 |
} |
704 | 708 |
|
... | ... |
@@ -739,34 +780,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) |
739 | 739 |
add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end); |
740 | 740 |
s->raw_packet_buffer_remaining_size -= pkt->size; |
741 | 741 |
|
742 |
- if(st->request_probe>0){ |
|
743 |
- AVProbeData *pd = &st->probe_data; |
|
744 |
- int end; |
|
745 |
- av_log(s, AV_LOG_DEBUG, "probing stream %d pp:%d\n", st->index, st->probe_packets); |
|
746 |
- --st->probe_packets; |
|
747 |
- |
|
748 |
- pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE); |
|
749 |
- memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size); |
|
750 |
- pd->buf_size += pkt->size; |
|
751 |
- memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE); |
|
752 |
- |
|
753 |
- end= s->raw_packet_buffer_remaining_size <= 0 |
|
754 |
- || st->probe_packets<=0; |
|
755 |
- |
|
756 |
- if(end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){ |
|
757 |
- int score= set_codec_from_probe_data(s, st, pd); |
|
758 |
- if( (st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4) |
|
759 |
- || end){ |
|
760 |
- pd->buf_size=0; |
|
761 |
- av_freep(&pd->buf); |
|
762 |
- st->request_probe= -1; |
|
763 |
- if(st->codec->codec_id != CODEC_ID_NONE){ |
|
764 |
- av_log(s, AV_LOG_DEBUG, "probed stream %d\n", st->index); |
|
765 |
- }else |
|
766 |
- av_log(s, AV_LOG_WARNING, "probed stream %d failed\n", st->index); |
|
767 |
- } |
|
768 |
- } |
|
769 |
- } |
|
742 |
+ probe_codec(s, st, pkt); |
|
770 | 743 |
} |
771 | 744 |
} |
772 | 745 |
|