• <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://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 閱讀(1712) 評論(0)  編輯 收藏 引用 所屬分類: GCC/G++跨平臺開發

            97久久超碰成人精品网站| 欧美亚洲国产精品久久| 久久天天躁狠狠躁夜夜网站 | 国产巨作麻豆欧美亚洲综合久久 | 97久久国产露脸精品国产| 久久久久久久波多野结衣高潮| 久久久久亚洲AV无码专区首JN | 99精品久久久久久久婷婷| 久久国产福利免费| 国产99久久久国产精品小说| 色婷婷久久综合中文久久蜜桃av| 久久亚洲国产欧洲精品一| 久久午夜福利电影| 成人妇女免费播放久久久| 久久亚洲国产精品五月天婷| 亚洲国产精品久久电影欧美| 99久久亚洲综合精品成人| 女人高潮久久久叫人喷水| av无码久久久久久不卡网站| 色天使久久综合网天天| 99re这里只有精品热久久| 奇米影视7777久久精品人人爽| 久久国产精品一区二区| 97久久国产综合精品女不卡 | 久久99国产亚洲高清观看首页 | 国产精品18久久久久久vr| 亚洲欧洲精品成人久久曰影片| 99re这里只有精品热久久| 久久精品国产99国产精品亚洲| 91精品国产高清久久久久久国产嫩草| 亚洲国产精品成人久久| 一级做a爰片久久毛片看看| 亚洲国产精品热久久| 国内精品久久久久| 精品久久久噜噜噜久久久| 99久久国产宗和精品1上映| 亚洲天堂久久久| 超级97碰碰碰碰久久久久最新| 九九热久久免费视频| 国产免费久久久久久无码| 久久免费精品视频|