• <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
            數(shù)據(jù)加載中……

            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 時才執(zhí)行 ff_probe_input_buffer 函數(shù), 因為 fmt 就等于NULL, 成立.


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


            關(guān)鍵的代碼片斷:
            /* 讀待探測的數(shù)據(jù) */
            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函數(shù), 有兩處比較關(guān)鍵:
            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函數(shù), 有一處比較關(guān)鍵:
            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函數(shù):
            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, 所以上面不成立, 繼續(xù)執(zhí)行 */ score = 0;
                if (fmt1->read_probe) {
                  score = fmt1->read_probe(pd); /* 調(diào)用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函數(shù):
            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://www.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 閱讀(1718) 評論(0)  編輯 收藏 引用 所屬分類: GCC/G++跨平臺開發(fā)

            久久夜色精品国产亚洲av| 中文字幕人妻色偷偷久久| 久久99国产精品久久99果冻传媒 | 久久夜色精品国产亚洲av| 国产精品久久久久久久app| 性欧美大战久久久久久久久| 久久夜色精品国产亚洲| 久久国产精品国语对白| 亚州日韩精品专区久久久| 国产∨亚洲V天堂无码久久久| 国产亚州精品女人久久久久久 | 精品久久久久久国产三级| 久久人人爽人人爽人人片AV高清 | 久久久久99精品成人片牛牛影视| 久久中文精品无码中文字幕| 久久免费的精品国产V∧| 热久久视久久精品18| 久久精品国产亚洲网站| 亚洲香蕉网久久综合影视| 亚洲精品无码久久久久久| 久久精品极品盛宴观看| 合区精品久久久中文字幕一区| 伊人久久大香线蕉精品| 色综合久久最新中文字幕| 国产视频久久| 综合网日日天干夜夜久久 | 91亚洲国产成人久久精品| 国产精品热久久毛片| 久久婷婷五月综合成人D啪| 久久久久亚洲av成人网人人软件| A级毛片无码久久精品免费| 91精品国产91久久综合| 久久高清一级毛片| 热re99久久精品国99热| 久久青青国产| 国産精品久久久久久久| 国产婷婷成人久久Av免费高清| 国产精品九九久久免费视频 | 九九精品99久久久香蕉| 久久久久九国产精品| 一本久久a久久精品综合夜夜|