[FFmpeg-devel] [PATCH] avformat/async: remove unuse code

Steven Liu lq at chinaffmpeg.org
Mon Nov 12 11:48:46 EET 2018


Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 libavformat/async.c | 208 ----------------------------------------------------
 1 file changed, 208 deletions(-)

diff --git a/libavformat/async.c b/libavformat/async.c
index 54dbd2312a..d755f3471b 100644
--- a/libavformat/async.c
+++ b/libavformat/async.c
@@ -489,211 +489,3 @@ const URLProtocol ff_async_protocol = {
     .priv_data_class     = &async_context_class,
 };
 
-#if 0
-
-#define TEST_SEEK_POS    (1536)
-#define TEST_STREAM_SIZE (2048)
-
-typedef struct TestContext {
-    AVClass        *class;
-    int64_t         logical_pos;
-    int64_t         logical_size;
-
-    /* options */
-    int             opt_read_error;
-} TestContext;
-
-static int async_test_open(URLContext *h, const char *arg, int flags, AVDictionary **options)
-{
-    TestContext *c = h->priv_data;
-    c->logical_pos  = 0;
-    c->logical_size = TEST_STREAM_SIZE;
-    return 0;
-}
-
-static int async_test_close(URLContext *h)
-{
-    return 0;
-}
-
-static int async_test_read(URLContext *h, unsigned char *buf, int size)
-{
-    TestContext *c = h->priv_data;
-    int          i;
-    int          read_len = 0;
-
-    if (c->opt_read_error)
-        return c->opt_read_error;
-
-    if (c->logical_pos >= c->logical_size)
-        return AVERROR_EOF;
-
-    for (i = 0; i < size; ++i) {
-        buf[i] = c->logical_pos & 0xFF;
-
-        c->logical_pos++;
-        read_len++;
-
-        if (c->logical_pos >= c->logical_size)
-            break;
-    }
-
-    return read_len;
-}
-
-static int64_t async_test_seek(URLContext *h, int64_t pos, int whence)
-{
-    TestContext *c = h->priv_data;
-    int64_t      new_logical_pos;
-
-    if (whence == AVSEEK_SIZE) {
-        return c->logical_size;
-    } else if (whence == SEEK_CUR) {
-        new_logical_pos = pos + c->logical_pos;
-    } else if (whence == SEEK_SET){
-        new_logical_pos = pos;
-    } else {
-        return AVERROR(EINVAL);
-    }
-    if (new_logical_pos < 0)
-        return AVERROR(EINVAL);
-
-    c->logical_pos = new_logical_pos;
-    return new_logical_pos;
-}
-
-#define OFFSET(x) offsetof(TestContext, x)
-#define D AV_OPT_FLAG_DECODING_PARAM
-
-static const AVOption async_test_options[] = {
-    { "async-test-read-error",      "cause read fail",
-        OFFSET(opt_read_error),     AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, .flags = D },
-    {NULL},
-};
-
-#undef D
-#undef OFFSET
-
-static const AVClass async_test_context_class = {
-    .class_name = "Async-Test",
-    .item_name  = av_default_item_name,
-    .option     = async_test_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
-const URLProtocol ff_async_test_protocol = {
-    .name                = "async-test",
-    .url_open2           = async_test_open,
-    .url_read            = async_test_read,
-    .url_seek            = async_test_seek,
-    .url_close           = async_test_close,
-    .priv_data_size      = sizeof(TestContext),
-    .priv_data_class     = &async_test_context_class,
-};
-
-int main(void)
-{
-    URLContext   *h = NULL;
-    int           i;
-    int           ret;
-    int64_t       size;
-    int64_t       pos;
-    int64_t       read_len;
-    unsigned char buf[4096];
-    AVDictionary *opts = NULL;
-
-    ffurl_register_protocol(&ff_async_protocol);
-    ffurl_register_protocol(&ff_async_test_protocol);
-
-    /*
-     * test normal read
-     */
-    ret = ffurl_open(&h, "async:async-test:", AVIO_FLAG_READ, NULL, NULL);
-    printf("open: %d\n", ret);
-
-    size = ffurl_size(h);
-    printf("size: %"PRId64"\n", size);
-
-    pos = ffurl_seek(h, 0, SEEK_CUR);
-    read_len = 0;
-    while (1) {
-        ret = ffurl_read(h, buf, sizeof(buf));
-        if (ret == AVERROR_EOF) {
-            printf("read-error: AVERROR_EOF at %"PRId64"\n", ffurl_seek(h, 0, SEEK_CUR));
-            break;
-        }
-        else if (ret == 0)
-            break;
-        else if (ret < 0) {
-            printf("read-error: %d at %"PRId64"\n", ret, ffurl_seek(h, 0, SEEK_CUR));
-            goto fail;
-        } else {
-            for (i = 0; i < ret; ++i) {
-                if (buf[i] != (pos & 0xFF)) {
-                    printf("read-mismatch: actual %d, expecting %d, at %"PRId64"\n",
-                           (int)buf[i], (int)(pos & 0xFF), pos);
-                    break;
-                }
-                pos++;
-            }
-        }
-
-        read_len += ret;
-    }
-    printf("read: %"PRId64"\n", read_len);
-
-    /*
-     * test normal seek
-     */
-    ret = ffurl_read(h, buf, 1);
-    printf("read: %d\n", ret);
-
-    pos = ffurl_seek(h, TEST_SEEK_POS, SEEK_SET);
-    printf("seek: %"PRId64"\n", pos);
-
-    read_len = 0;
-    while (1) {
-        ret = ffurl_read(h, buf, sizeof(buf));
-        if (ret == AVERROR_EOF)
-            break;
-        else if (ret == 0)
-            break;
-        else if (ret < 0) {
-            printf("read-error: %d at %"PRId64"\n", ret, ffurl_seek(h, 0, SEEK_CUR));
-            goto fail;
-        } else {
-            for (i = 0; i < ret; ++i) {
-                if (buf[i] != (pos & 0xFF)) {
-                    printf("read-mismatch: actual %d, expecting %d, at %"PRId64"\n",
-                           (int)buf[i], (int)(pos & 0xFF), pos);
-                    break;
-                }
-                pos++;
-            }
-        }
-
-        read_len += ret;
-    }
-    printf("read: %"PRId64"\n", read_len);
-
-    ret = ffurl_read(h, buf, 1);
-    printf("read: %d\n", ret);
-
-    /*
-     * test read error
-     */
-    ffurl_close(h);
-    av_dict_set_int(&opts, "async-test-read-error", -10000, 0);
-    ret = ffurl_open(&h, "async:async-test:", AVIO_FLAG_READ, NULL, &opts);
-    printf("open: %d\n", ret);
-
-    ret = ffurl_read(h, buf, 1);
-    printf("read: %d\n", ret);
-
-fail:
-    av_dict_free(&opts);
-    ffurl_close(h);
-    return 0;
-}
-
-#endif
-- 
2.15.2 (Apple Git-101.1)





More information about the ffmpeg-devel mailing list