• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere

            路漫漫,長修遠,我們不能沒有錢
            隨筆 - 173, 文章 - 0, 評論 - 257, 引用 - 0
            數據加載中……

            ffmpeg分析系列之六(再次探測輸入的格式)

            void *logctx= ap && ap->prealloced_context ? *ic_ptr : NULL; // 因為 ap == NULL, 所以 logctx 也 == NULL.
            if (!fmt && (err = ff_probe_input_buffer(&pb, &fmt, filename, logctx, 0, logctx ? (*ic_ptr)->probesize : 0)) < 0) {
              goto fail;
            }
            // fmt == NULL 時才執行 ff_probe_input_buffer 函數, 因為 fmt 就等于NULL, 成立.


            ff_probe_input_buffer函數的原型:
            int ff_probe_input_buffer(ByteIOContext **pb, // 字節IO上下文, 執行url_fopen得到的
                AVInputFormat **fmt, // 輸出參數: 輸入的格式
                const char *filename, // 文件名
                void *logctx, // NULL
                unsigned int offset, // 0
                unsigned int max_probe_size) // 0


            關鍵的代碼片斷:
            /* 讀待探測的數據 */
            buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);
            if ((ret = get_buffer(*pb, buf + buf_offset, probe_size - buf_offset)) < 0) {
              /* fail if error was not end of file, otherwise, lower score */
              if (ret != AVERROR_EOF) {
                av_free(buf);
                return ret;
              }
              score = 0;
              ret = 0; /* error was end of file, nothing read */
            }
            pd.buf_size += ret;
            pd.buf = &buf[offset];

            memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);

            /* 猜測文件格式 */
            *fmt = av_probe_input_format2(&pd, 1, &score);

            get_buffer函數, 有兩處比較關鍵:
            int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
            {

              /* 省略部分代碼 */ /* 讀包 */
              if(s->read_packet)
                len = s->read_packet(s->opaque, buf, size);


              /* 省略部分代碼 */

              /* 填充緩沖 */

              fill_buffer(s);

              /* 省略部分代碼 */

            }





            fill_buffer函數, 有一處比較關鍵:
            static void fill_buffer(ByteIOContext *s)
            { /* 省略部分代碼 */ /* 讀包 */
              if(s->read_packet)
                len = s->read_packet(s->opaque, dst, len);

            /* 省略部分代碼 */
            }





            好了, 到第二次探測輸入格式的地方了:
            *fmt = av_probe_input_format2(&pd, 1, &score);


            進入av_probe_input_format2函數:
            AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
            {
              AVInputFormat *fmt1, *fmt;
              int score;

              fmt = NULL;
              for(fmt1 = first_iformat; fmt1 != NULL; fmt1 = fmt1->next) {
                if (!is_opened == !(fmt1->flags & AVFMT_NOFILE))
                  continue;

                /* 這次 is_opened == 1, fmt1->flags設置AVFMT_NOFILE標志才時成立 */

                /* 由于 h264_demuxer.flags == AVFMT_GENERIC_INDEX, 所以上面不成立, 繼續執行 */ score = 0;
                if (fmt1->read_probe) {
                  score = fmt1->read_probe(pd); /* 調用h264_demuxer.h264_probe */
                } else if (fmt1->extensions) {
                  if (av_match_ext(pd->filename, fmt1->extensions)) { /* 文件名和格式擴展名的匹配 */

                    /* h264_demuxer.extensions = "h26l,h264,264" */ score = 50;
                  }
                }
             if (score > *score_max) {
                *score_max = score;
                fmt = fmt1;
              }else if (score == *score_max)
                fmt = NULL;
              }
              return fmt;
            }

            av_match_ext函數:
            int av_match_ext(const char *filename, const char *extensions)
            {
              const char *ext, *p;
              char ext1[32], *q;

              if(!filename)
                return 0;

              ext = strrchr(filename, '.');
              if (ext) {
                ext++;
                p = extensions;
                for(;;) {
                  q = ext1;
                  while (*p != '' && *p != ',' && q-ext1<sizeof(ext1)-1)
                    *q++ = *p++;
                  *q = '';
                  if (!strcasecmp(ext1, ext))
                    return 1;
                  if (*p == '')
                    break;
                  p++;
                }
              }
              return 0;
            }




            @import url(http://m.shnenglu.com/cutesoft_client/cuteeditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

            posted on 2012-12-14 01:44 Khan 閱讀(1712) 評論(0)  編輯 收藏 引用 所屬分類: GCC/G++ 、跨平臺開發

            99久久99久久精品国产片| 国产麻豆精品久久一二三| 久久久噜噜噜久久熟女AA片| 久久综合狠狠综合久久| 国内精品综合久久久40p| 97久久超碰国产精品旧版| 一本久久综合亚洲鲁鲁五月天| 一本色道久久99一综合| 91久久香蕉国产熟女线看| 国内精品九九久久精品| 99热精品久久只有精品| 久久ZYZ资源站无码中文动漫 | 久久久久亚洲精品中文字幕| 久久人妻AV中文字幕| 人妻系列无码专区久久五月天| 国产成人久久AV免费| 五月丁香综合激情六月久久| 无码人妻少妇久久中文字幕| 欧美777精品久久久久网| 精品久久久久久无码人妻蜜桃| 99久久综合狠狠综合久久止| 97热久久免费频精品99| 日本久久久久亚洲中字幕| 中文字幕人妻色偷偷久久| 伊人久久大香线蕉av一区| 精品久久久久中文字幕日本| 99久久国产热无码精品免费久久久久| 免费精品国产日韩热久久| 久久久精品久久久久特色影视| 色综合久久天天综线观看| 久久无码专区国产精品发布| 伊人久久大香线蕉综合影院首页| 久久久一本精品99久久精品66 | 亚洲第一永久AV网站久久精品男人的天堂AV | 国产精品久久久久a影院| 久久青青草原国产精品免费| 蜜臀久久99精品久久久久久| 91精品国产9l久久久久| 国产精品久久久久久久久软件 | 久久久无码人妻精品无码| 亚洲午夜福利精品久久|