diff mbox

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

Message ID 20181112094846.87770-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Liu Steven Nov. 12, 2018, 9:48 a.m. UTC
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/async.c | 208 ----------------------------------------------------
 1 file changed, 208 deletions(-)

Comments

Michael Niedermayer Nov. 12, 2018, 10:17 p.m. UTC | #1
On Mon, Nov 12, 2018 at 05:48:46PM +0800, Steven Liu wrote:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/async.c | 208 ----------------------------------------------------
>  1 file changed, 208 deletions(-)

Is this test done elsewhere ? (i think its not but i may have missed it)
If not then this should not be removed but rather repaired and enabled again

thx

[...]
Liu Steven Nov. 13, 2018, 2:09 a.m. UTC | #2
> 在 2018年11月13日,上午6:17,Michael Niedermayer <michael@niedermayer.cc> 写道:
> 
> On Mon, Nov 12, 2018 at 05:48:46PM +0800, Steven Liu wrote:
>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>> ---
>> libavformat/async.c | 208 ----------------------------------------------------
>> 1 file changed, 208 deletions(-)
> 
> Is this test done elsewhere ? (i think its not but i may have missed it)
> If not then this should not be removed but rather repaired and enabled again
Do you mean add and CONFIG for the compile, make it enabled?
> 
> thx
> 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> In fact, the RIAA has been known to suggest that students drop out
> of college or go to community college in order to be able to afford
> settlements. -- The RIAA
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Michael Niedermayer Nov. 13, 2018, 10:29 a.m. UTC | #3
On Tue, Nov 13, 2018 at 10:09:55AM +0800, Liu Steven wrote:
> 
> 
> > 在 2018年11月13日,上午6:17,Michael Niedermayer <michael@niedermayer.cc> 写道:
> > 
> > On Mon, Nov 12, 2018 at 05:48:46PM +0800, Steven Liu wrote:
> >> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> >> ---
> >> libavformat/async.c | 208 ----------------------------------------------------
> >> 1 file changed, 208 deletions(-)
> > 
> > Is this test done elsewhere ? (i think its not but i may have missed it)
> > If not then this should not be removed but rather repaired and enabled again
> Do you mean add and CONFIG for the compile, make it enabled?

its there but commented out, yes it should be re-enabled in think.
I dont remember exactly what was the problem but it surely will need some
change to work again. I think there was some internal API use issue but
i might misremember

thanks

[...]
diff mbox

Patch

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